Ejemplo n.º 1
0
 public OrderChunk(EnumProvider.ORDERSLIST order, Vector3 point, int priorityAndOrID)
 {
     this.order = order;
     floats     = new float[3];
     floats[0]  = point.x;
     floats[1]  = point.y;
     floats[2]  = point.z;
     data       = priorityAndOrID;
 }
Ejemplo n.º 2
0
 public OrderChunk(EnumProvider.ORDERSLIST order,Vector3 point,int priorityAndOrID)
 {
     this.order = order;
     floats = new float[3];
     floats[0] = point.x;
     floats[1] = point.y;
     floats[2] = point.z;
     data = priorityAndOrID;
 }
Ejemplo n.º 3
0
    public int RegisterUnitComponent(UnitComponent component, System.Enum[] stateExtensions)
    {
        bool add      = true;
        int  UCcompID = -1;

        if (PluggedStateExtendingComponents.ContainsValue(component))
        {
            foreach (int key in PluggedStateExtendingComponents.Keys)
            {
                if (component == PluggedStateExtendingComponents[key])
                {
                    UCcompID = key;
                    Component.Destroy(component);
                    return(UCcompID);
                }
            }
        }
        else
        {
            foreach (System.Enum extension in stateExtensions)
            {
                EnumProvider.ORDERSLIST KEY = (EnumProvider.ORDERSLIST)extension;
                if (KEY < EnumProvider.ORDERSLIST.Cancel)
                {
                    string VALUE = System.Enum.GetName(typeof(EnumProvider.ORDERSLIST), KEY);
                    if ((int)KEY > (int)EnumProvider.ORDERSLIST.Stay)
                    {
                        OptionalStatesOrder.Remove((int)KEY);
                    }
                    if (!OptionalStatesOrder.ContainsKey((int)KEY))
                    {
                        OptionalStatesOrder.Add((int)KEY, VALUE);
                    }
                }
                else
                {
                    add = false;
                }
            }
            if (add)
            {
                UCcompID = PluggedStateExtendingComponents.Count;
                PluggedStateExtendingComponents.Add(UCcompID, component);

                optionalstateIDs = RefreshStatelist();
            }
        }
        return(UCcompID);
    }
Ejemplo n.º 4
0
    protected override EnumProvider.ORDERSLIST on_UnitStateChange(EnumProvider.ORDERSLIST stateorder)
    {
        //Debug.Log("OnUnitStateChange called!!!!!!!!!!!!!!!");
        movingUnitState = (OPTIONS)stateorder;
        if (!UNIT.Options.standardOrder)
        {
            if (System.Enum.IsDefined(typeof(OPTIONS), (int)stateorder))
            {
                switch (movingUnitState)
                {
                case OPTIONS.MoveTo:
                    SetKinematic();
                    WayPoints.Clear();
                    UNIT.InteractingUnits.Clear();
                    UNIT.Options.LockOnFocus();
                    return(stateorder);

                case OPTIONS.Patrol:
                    SetKinematic();
                    UNIT.InteractingUnits.Clear();
                    UNIT.Options.LockOnFocus();
                    return(stateorder);

                case OPTIONS.Guard:
                    SetKinematic();
                    WayPoints.Clear();
                    UNIT.InteractingUnits.Clear();
                    UNIT.Options.LockOnFocus();
                    return(stateorder);

                case OPTIONS.Hide:
                    WayPoints.Clear();
                    SetKinematic();
                    //todo:-----------------
                    return(stateorder);

                case OPTIONS.Stay:
                    SetKinematic();
                    WayPoints.Clear();
                    MoveToPoint     = gameObject.transform.position;
                    MovingDirection = MoveToPoint;
                    UNIT.InteractingUnits.Clear();

                    return(stateorder);
                }
            }
        }
        return(stateorder);
    }
Ejemplo n.º 5
0
    protected override EnumProvider.ORDERSLIST on_UnitStateChange(EnumProvider.ORDERSLIST stateorder)
    {
        attackState = (OPTIONS)stateorder;
        if (!UNIT.Options.standardOrder)
        {
            if (System.Enum.IsDefined(typeof(OPTIONS), (int)stateorder))
            {
                switch (attackState)
                {
                case OPTIONS.Attack:
                    if (!UNIT.IsABuilding)
                    {
                        this.GetComponent <Movability>().SetKinematic();
                        this.GetComponent <Movability>().WayPoints.Clear();
                        UNIT.Options.MoveToPoint = this.gameObject.transform.position;
                        this.GetComponent <Movability>().IsMoving = false;
                    }
                    Debug.Log("ATTACKE!!!");
                    UNIT.Options.LockOnFocus();
                    return(stateorder);

                case OPTIONS.Conquer:
                    if (!GetComponent <Gunner>())
                    {
                        this.gameObject.AddComponent <Gunner>();
                    }
                    UNIT.Options.UnitState = EnumProvider.ORDERSLIST.Stay;
                    if (!UNIT.IsABuilding)
                    {
                        UNIT.Options.LockOnFocus();
                    }
                    GetComponent <Gunner>().FireAtWill = true;
                    return(stateorder);

                case OPTIONS.Seek:
                    if (!GetComponent <Gunner>())
                    {
                        this.gameObject.AddComponent <Gunner>();
                    }

                    return(stateorder);
                }
            }
        }
        return(stateorder);
    }
Ejemplo n.º 6
0
    public void UnRegister(int componentID, System.Enum[] extensions)
    {
        bool NeedRefreshList = true;

        for (int i = extensions.Length - 1; i >= 0; i--)
        {
            EnumProvider.ORDERSLIST KEY = (EnumProvider.ORDERSLIST)extensions[i];
            //string VALUE = System.Enum.GetName(typeof(EnumProvider.ORDERSLIST), extensions[i]);
            if (KEY != EnumProvider.ORDERSLIST.Cancel)
            {
                OptionalStatesOrder.Remove((int)KEY);
                if (KEY > EnumProvider.ORDERSLIST.Stay)
                {
                    if (UNIT.IsABuilding)
                    {
                        OptionalStatesOrder.Add((int)EnumProvider.ORDERSLIST.StopProduction, System.Enum.GetNames(typeof(EnumProvider.ORDERSLIST))[(int)EnumProvider.ORDERSLIST.StopProduction]);
                    }
                    else
                    {
                        OptionalStatesOrder.Add((int)EnumProvider.ORDERSLIST.Stay, System.Enum.GetNames(typeof(EnumProvider.ORDERSLIST))[(int)EnumProvider.ORDERSLIST.Stay]);
                    }
                }
            }
            else
            {
                NeedRefreshList = false;
            }
        }
        if (NeedRefreshList)
        {
            optionalstateIDs = RefreshStatelist();
        }
        if (componentID >= 0)
        {
            PluggedStateExtendingComponents.Remove(componentID);
        }
    }
Ejemplo n.º 7
0
 protected override EnumProvider.ORDERSLIST on_UnitStateChange(EnumProvider.ORDERSLIST stateorder)
 {
     return(stateorder);
 }
Ejemplo n.º 8
0
 virtual internal void GiveOrder(EnumProvider.ORDERSLIST order)
 {
     UnitState = order;
 }
Ejemplo n.º 9
0
 public void AddOrder(EnumProvider.ORDERSLIST order, Vector3 point, int id)
 {
     orderList.Add(new OrderChunk(order, point, id));
 }
Ejemplo n.º 10
0
 abstract protected EnumProvider.ORDERSLIST on_UnitStateChange(EnumProvider.ORDERSLIST stateorder);