Exemplo n.º 1
0
    void Update()
    {
        if (allegiance)
        {
            // Update loyalty.
            float sumOfOtherQueens = 0f;

            Influential[] queens = Object.FindObjectsOfType(typeof(Influential)) as Influential[];

            foreach (Influential queen in queens)
            {
                float power = queen.Power(transform.root.position);

                if (power > 0)
                {
                    sumOfOtherQueens += power;
                }
            }

            loyalty = allegiance.Power(transform.root.position) - 0 * sumOfOtherQueens;

            if (loyalty < 0)
            {
                allegiance = null;
            }
        }
        else
        {
            // Feral!
            allegiance = GetStrongestQueen();
        }
    }
Exemplo n.º 2
0
    protected Influential GetStrongestQueen()
    {
        Influential[] queens = Object.FindObjectsOfType(typeof(Influential)) as Influential[];
        Influential   queen  = null;
        float         power  = 0f;

        foreach (Influential heir in queens)
        {
            float tempPower = heir.Power(transform.root.position);

            if (tempPower > power)
            {
                queen = heir;
                power = tempPower;
            }
        }

        return(queen);
    }
Exemplo n.º 3
0
    void Update()
    {
        // Test for clicks
        if (Input.GetButtonDown("Move"))
        {
            RaycastHit hitInfo;

            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo, Mathf.Infinity, Layers.Map))
            {
                // Spawn a marker
                if (!tempCircle)
                {
                    tempCircle = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                }

                tempCircle.transform.position   = hitInfo.point;
                tempCircle.transform.localScale = new Vector3(10, 10, 10);

                // Move the unit to the point
                Selector selectGroup = transform.root.GetComponent <Selector>();

                if (selectGroup)
                {
                    foreach (Selectable unit in selectGroup.SelectedUnits)
                    {
                        Loyal       loyalty = unit.GetComponent <Loyal>();
                        Influential queen   = unit.GetComponent <Influential>();
                        Movable     action  = unit.GetComponent <Movable>();

                        if (action && ((loyalty && loyalty.allegiance == player.queen) || (queen && queen == player.queen)))
                        {
                            action.Move(hitInfo.point);
                        }
                    }
                }
            }
        }
    }