Пример #1
0
 /// <summary>
 /// This method should only be used by GridDweller. Use that component to represent something on
 /// the grid. Never interact with this method directly. Throws an exception if trying to set
 /// a non-emtpy cell to something non-empty, or if trying to set an empty cell as empty again.
 /// </summary>
 public void RemoveDwellerFromCell(CellPosition position, GridDweller dweller)
 {
     if (position.side == GridClass.PlayerGrid)
     {
         playerSideContents[position.x, position.z].Remove(dweller);
     }
     else
     {
         enemySideContents[position.x, position.z].Remove(dweller);
     }
 }
Пример #2
0
 /// <summary>
 /// This method should only be used by GridDweller. Use that component to represent something on
 /// the grid. Never interact with this method directly. Throws an exception if trying to set
 /// a non-emtpy cell to something non-empty, or if trying to set an empty cell as empty again.
 /// </summary>
 public void AddDwellerToCell(CellPosition position, GridDweller dweller)
 {
     if (position.side == GridClass.PlayerGrid)
     {
         playerSideContents[position.x, position.z].Add(dweller);
     }
     else
     {
         enemySideContents[position.x, position.z].Add(dweller);
     }
 }
Пример #3
0
    public GridDweller[] CellContents(CellPosition position)
    {
        GridDweller[] contents = new GridDweller[] { };

        if (IsValid(position))
        {
            if (position.side == GridClass.PlayerGrid)
            {
                return(playerSideContents[position.x, position.z].ToArray());
            }
            else if (position.side == GridClass.EnemyGrid)
            {
                return(enemySideContents[position.x, position.z].ToArray());
            }
        }

        return(contents);
    }
Пример #4
0
    void Update()
    {
        //Vector3 curPos = transform.position;
        //dweller.SyncCellPositionToRealPosition();
        //transform.Translate(velocity * Time.deltaTime);
        //curPos += velocity * Time.deltaTime;
        transform.position += velocity * Time.deltaTime;

        GridDweller[] contents = dweller.GetGridWorld().CellContents(dweller.GetCurrentCell());
        GridDweller   player   = contents.FirstOrDefault((gd) => gd.type == DwellerType.Player);

        //if(dweller.GetGridWorld().IsTypeInCell(dweller.GetCurrentCell(), DwellerType.Player)) {
        if (player != null)
        {
            // TODO: Deduct health.
            //Debug.Log("HIT THE PLAYER! (TODO: DEDUCT HEALTH)");

            player.GetComponentInParent <Health>().TakeDamage(DamageType.Damage, damage);
            Destroy(gameObject);
        }
    }
Пример #5
0
    /*
     * public void SetVelocity(Vector3 newVelocity) {
     * velocity = newVelocity;
     * }
     */

    void Start()
    {
        dweller = GetComponent <GridDweller>();
        //SetVelocity(Vector3.back * 4.0f);
        //velocity = Vector3.back * 4.0f;
    }
Пример #6
0
 void Start()
 {
     dweller = GetComponent <GridDweller>();
 }
Пример #7
0
 void Start()
 {
     dweller = GetComponent <GridDweller>();
     dweller.StartAt(GetRandomCell());
 }
Пример #8
0
 void Start()
 {
     dweller = GetComponent <GridDweller>();
     ResetMoveTimer();
 }