EventFactory.CreateEvent C# (CSharp) Method

CreateEvent() public method

public CreateEvent ( string someCondition ) : IEvent,
someCondition string
return IEvent,
        public IEvent CreateEvent(string someCondition)
        {
            switch(SomeCondition){
                case "FirstCondition":
                    return new EventA();
                case "SecondCondition":
                    return new EventB(); 
                case "ThirdCondition":
                    return new EventC();
                case "FourthCondition":
                    return new EventD();
        }
    }

Usage Example

    /**
     * TODO will be called every turn regardless of weather it is moved or not in order to count turns in air
     */
    public override void MoveAsPlanned(Vector3 newPos)
    {
        TurnsNotLanded++;
        if (TurnsNotLanded >= MaxTurnsAirborne)
        {
            // Create a DieEvent
            object[] arguments = new object[1];
            arguments[0] = (this.gameObject.GetComponent <IdentityController>()).GetGuid();
            EventManager.Instance.AddEvent(EventFactory.CreateEvent(GEventType.DieEvent, arguments));
        }
        else
        {
            // Modify the CurrentRange by the distance traveled
            CurrentRange -= Vector3.Distance(newPos, this.gameObject.transform.position);

            // If the unit has moved outside of its current range
            if (CurrentRange < 0)
            {
                // Create a DieEvent
                object[] arguments = new object[1];
                arguments[0] = (this.gameObject.GetComponent <IdentityController>()).GetGuid();
                EventManager.Instance.AddEvent(EventFactory.CreateEvent(GEventType.DieEvent, arguments));
            }
            else
            {
                base.MoveAsPlanned(newPos);
            }
        }
    }
All Usage Examples Of EventFactory::CreateEvent
EventFactory