예제 #1
0
    void Start()
    {
        gridWorld = GridWorld.getInstance();
        allCells  = gridWorld.ListAllCells();
        foreach (CellPosition cell in allCells)
        {
            PhysicalCell physicalCell = new PhysicalCell();
            physicalCell.position = gridWorld.GetRealPosition(cell);
            Instantiate(cellPrefab, physicalCell.position);

            /*
             * if (optionalPlayerEffect != null) {
             * GameObject playerEffect = Instantiate(optionalPlayerEffect, physicalCell.position);
             * physicalCell.playerEffect = playerEffect.GetComponentInChildren<ParticleSystem>();
             * physicalCell.playerEffect.Stop();
             * }
             *
             * if (optionalEnemyEffect != null) {
             * GameObject enemyEffect = Instantiate(optionalEnemyEffect, physicalCell.position);
             * physicalCell.enemyEffect = enemyEffect.GetComponentInChildren<ParticleSystem>();
             * physicalCell.enemyEffect.Stop();
             * }
             */

            foreach (DwellerInfo info in dwellerInfoSet)
            {
                physicalCell.data.Add(info.type, new PhysicalCell.TypeSpecificData());

                if (info.optionalEffect != null)
                {
                    GameObject effect = Instantiate(info.optionalEffect, physicalCell.position);
                    physicalCell.data[info.type].effect = effect.GetComponentInChildren <ParticleSystem>();
                    physicalCell.data[info.type].effect.Stop();
                }
            }

            physicalCells.Add(physicalCell);
        }
    }
예제 #2
0
    void Update()
    {
        for (int i = 0; i < allCells.Count; i++)
        {
            CellPosition cellPosition = allCells[i];
            PhysicalCell physicalCell = physicalCells[i];

            foreach (DwellerInfo generalTypeInfo in dwellerInfoSet)
            {
                if (gridWorld.IsTypeInCell(cellPosition, generalTypeInfo.type))
                {
                    if (physicalCell.data[generalTypeInfo.type].indicator == null)
                    {
                        physicalCell.data[generalTypeInfo.type].indicator =
                            Instantiate(generalTypeInfo.indicatorPrefab, physicalCell.position);
                        if (physicalCell.data[generalTypeInfo.type].effect != null)
                        {
                            physicalCell.data[generalTypeInfo.type].effect.Play();
                        }
                    }
                }
                else
                {
                    if (physicalCell.data[generalTypeInfo.type].indicator != null)
                    {
                        Destroy(physicalCell.data[generalTypeInfo.type].indicator);
                        physicalCell.data[generalTypeInfo.type].indicator = null;
                        if (physicalCell.data[generalTypeInfo.type].effect != null)
                        {
                            physicalCell.data[generalTypeInfo.type].effect.Stop();
                        }
                    }
                }
            }
        }
    }
예제 #3
0
 /// <summary>
 /// Callback for placing pieces, called upon reaching cell
 /// </summary>
 /// <param name="piece">The piece gameObject</param>
 /// <param name="newCell">Cell in which to place piece</param>
 private void placePiece(GameObject piece, PhysicalCell newCell)
 {
     newCell.Place(piece);
 }
예제 #4
0
 /// <summary>
 /// Callback for grasping pieces, called upon reaching target
 /// </summary>
 /// <param name="cell">Cell from where to get piece</param>
 /// <param name="arm">The arm that should take the piece</param>
 private void graspPiece(PhysicalCell cell, ActorMotion.Arm arm)
 {
     GameObject p = cell.RemovePiece();
     p.transform.SetParent(arm.transform);
     p.transform.localPosition = Vector3.zero;
     arm.holding = p.transform;
 }