コード例 #1
0
ファイル: Ball.cs プロジェクト: andykessler/LudumDare40
 public void Capture(BallHunter bh)
 {
     if (Owner != null)
     {
         GameLoop.carriersFree.Add(Owner);
         Owner.ball = null;
     }
     //bh.Precious = null;
     Owner = null;
 }
コード例 #2
0
    static void SendFreeHunters()
    {
        // TODO Send out no more than MAX count (will allow decrease over time)
        //int extraBalls = hunters.Count - maxBallCount;
        for (int i = huntersFree.Count - 1; i >= 0; i--)
        {
            BallHunter bh = huntersFree[i];
            //bh.transform.position = Vector3.zero; // undo the hiding!
            bh.SendMessage("FindPrecious"); // FIXME if all precious occupied but there is at least 1 precious, go after it
            bh.SendMessage("ChasePrecious");

            if (bh.Precious != null)
            {
                huntersFree.RemoveAt(i);
                //removeFreeHunterEvent();
            }
        }
    }
コード例 #3
0
    // Create any extra hunters we can make now, but do not assign ownership yet
    // TODO Hides the hunter from display until needed
    static void CreateHunterPool()
    {
        if (hunters.Count < maxHunterCount)
        {
            float amplitude    = scale.z * (5f * 0.5f); // TODO remove magic numbers
            float radian_ratio = (2 * Mathf.PI) / GameProperties.hunters;
            for (int i = hunters.Count; i < maxHunterCount; i++)
            {
                Transform  t  = Instantiate(hunterPrefab, carrierOffsetY, Quaternion.identity);
                BallHunter bh = t.GetComponent <BallHunter>();

                float   r = radian_ratio * i;
                Vector3 v = new Vector3(Mathf.Cos(r), 0f, Mathf.Sin(r));
                t.position += v * amplitude;
                t.LookAt(Vector3.up * t.transform.position.y);

                hunters.Add(bh);
                huntersFree.Add(bh); // TODO Hide until needed, use add/remove listener to toggle display
                //addFreeHunterEvent();
            }
        }
    }