Example #1
0
 public void InitPositionType()
 {
     if (coords.iColumn == 0 || coords.iColumn == 5)
     {
         positiontype = POSITIONTYPE.BENCH;
     }
     else if (coords.iColumn == 1 || coords.iColumn == 4)
     {
         positiontype = POSITIONTYPE.BACKLINE;
     }
     else
     {
         positiontype = POSITIONTYPE.FRONTLINE;
     }
 }
        /// <summary>
        /// Nos da las posiciones finales en donde vamos a mover a nuestras unidades
        /// Ahora las acomode de la mas debil a la mas fuerte en posiciones
        /// </summary>
        /// <param name="tilePosition">La tile a donde se van a mover</param>
        /// <param name="positionType">De que forma van a acomodar en esa tile</param>
        /// <returns></returns>
        public Vector3[] GetPositions(Vector3 tilePosition, POSITIONTYPE positionType)
        {
            Vector3[] shapePosition;
            switch (positionType)
            {
            case POSITIONTYPE.CENTER:
                shapePosition    = new Vector3[1];
                shapePosition[0] = tilePosition + new Vector3(offsetPosition * CardinalPosition.CENTER.x, offsetPosition * CardinalPosition.CENTER.y, 0);
                break;

            case POSITIONTYPE.ARROW:
                shapePosition    = new Vector3[2];
                shapePosition[0] = tilePosition + new Vector3(offsetPosition * CardinalPosition.EAST.x, offsetPosition * CardinalPosition.EAST.y, 0);
                shapePosition[1] = tilePosition + new Vector3(offsetPosition * CardinalPosition.WEST.x, offsetPosition * CardinalPosition.WEST.y, 0);
                break;

            case POSITIONTYPE.BOW:
                shapePosition    = new Vector3[3];
                shapePosition[0] = tilePosition + new Vector3(offsetPosition * CardinalPosition.EAST.x, offsetPosition * CardinalPosition.EAST.y, 0);
                shapePosition[1] = tilePosition + new Vector3(offsetPosition * CardinalPosition.NORTH.x, offsetPosition * CardinalPosition.NORTH.y, 0);
                shapePosition[2] = tilePosition + new Vector3(offsetPosition * CardinalPosition.SOUTH.x, offsetPosition * CardinalPosition.SOUTH.y, 0);
                break;

            case POSITIONTYPE.DIAMOND:
                shapePosition    = new Vector3[4];
                shapePosition[0] = tilePosition + new Vector3(offsetPosition * CardinalPosition.EAST.x, offsetPosition * CardinalPosition.EAST.y, 0);
                shapePosition[1] = tilePosition + new Vector3(offsetPosition * CardinalPosition.NORTH.x, offsetPosition * CardinalPosition.NORTH.y, 0);
                shapePosition[2] = tilePosition + new Vector3(offsetPosition * CardinalPosition.SOUTH.x, offsetPosition * CardinalPosition.SOUTH.y, 0);
                shapePosition[3] = tilePosition + new Vector3(offsetPosition * CardinalPosition.WEST.x, offsetPosition * CardinalPosition.WEST.y, 0);
                break;

            case POSITIONTYPE.SQUARE:
                shapePosition    = new Vector3[4];
                shapePosition[0] = tilePosition + new Vector3(offsetPosition * CardinalPosition.NORTHEAST.x, offsetPosition * CardinalPosition.NORTHEAST.y, 0);
                shapePosition[1] = tilePosition + new Vector3(offsetPosition * CardinalPosition.NORTHWEST.x, offsetPosition * CardinalPosition.NORTHWEST.y, 0);
                shapePosition[2] = tilePosition + new Vector3(offsetPosition * CardinalPosition.SOUTHEAST.x, offsetPosition * CardinalPosition.SOUTHEAST.y, 0);
                shapePosition[3] = tilePosition + new Vector3(offsetPosition * CardinalPosition.SOUTHWEST.x, offsetPosition * CardinalPosition.SOUTHWEST.y, 0);
                break;

            default:
                shapePosition = new Vector3[0];
                break;
            }
            return(shapePosition);
        }
        public Motion RearangePositionAfterCombineMotion(List <GameObject> kimbokos, Vector3 actualPosition, int reproductionOrder = 1)
        {
            List <Motion>      motionsSpawnCombine = new List <Motion>();
            UnitMovePositioner movePositioner      = new UnitMovePositioner(4f);

            //  - DESPUES ME DEBERIA FIJAR SI TENGO ENEMIGOS EN LA QUE SELECCIONE, Y SI TENGO DEBERIA AGREGAR EL COMANDO DE REPOSICIONARLOS
            if (kimbokos.Count > 1)
            {
                POSITIONTYPE positionTypeToRearrange = movePositioner.GetPositionType(kimbokos.Count);
                Vector3[]    finalRearrangePositions = movePositioner.GetPositions(actualPosition, positionTypeToRearrange);
                // SONIDO DE CUANDO SE MUEVEN PARA REPOSICIONARSE
                if (GameSoundManager.Instance != null)
                {
                    if (GameSoundManager.Instance.audioSource != null)
                    {
                        Motion motionMoveSound = new SoundMotion(this, 1, GameSoundManager.Instance.audioSource, GameSoundManager.Instance.audioClips[4], false, true);
                        motionsSpawnCombine.Add(motionMoveSound);
                    }
                }

                // deberia recorrer la lista de unidades, y generar una move comand para posicionarse en el lugar que tiene cada una del cuadrado
                for (int i = 0; i < kimbokos.Count; i++)
                {
                    List <Motion> motionsCombineSpawnMoveSquare = new List <Motion>();
                    int           shortNameHash = Animator.StringToHash("Base Layer" + ".Idlle");
                    Animator      animatorAux   = kimbokos[i].GetComponent <Animator>();
                    // LOS PONGO EN ESTADO MOVE PARA LA ANIMACION
                    Motion motionMove = new MoveMotion(this, animatorAux, 1, false, shortNameHash);
                    //Motion motionMove = new MoveMotion(this, animatorAux, 1);
                    motionsSpawnCombine.Add(motionMove);

                    List <Motion> motionsCombineSpawnStopMoveSquare = new List <Motion>();
                    // LOS MUEVO DESDE DONDE ESTAN HASTA LA POSICION FINAL
                    Motion motionTwMove = new MoveTweenMotion(this, kimbokos[i].transform, 1, finalRearrangePositions[i], 1);
                    motionsCombineSpawnStopMoveSquare.Add(motionTwMove);
                    // LOS PONGO EN ESTADO IDLLE
                    Motion motionIdlle = new IdlleMotion(this, animatorAux, 2, true);
                    motionsCombineSpawnStopMoveSquare.Add(motionIdlle);

                    // esto solo lo hago para detener el sonido de los pasos
                    if (kimbokos.Count - 1 == i)
                    {
                        List <Configurable> configurables = new List <Configurable>();

                        if (GameSoundManager.Instance != null)
                        {
                            if (GameSoundManager.Instance.audioSource != null)
                            {
                                AudioSourceGenericContainer audioContainer = new AudioSourceGenericContainer(GameSoundManager.Instance.audioSource);
                                StopSoundConfigureAnimotion <AudioSourceGenericContainer, Transform> stopSoundConfigureAnimotion
                                    = new StopSoundConfigureAnimotion <AudioSourceGenericContainer, Transform>(audioContainer, 2);
                                configurables.Add(stopSoundConfigureAnimotion);
                            }
                        }
                        CombineMotion combineStopMotion = new CombineMotion(this, 1, motionsCombineSpawnStopMoveSquare, configurables);
                        motionsCombineSpawnMoveSquare.Add(combineStopMotion);
                    }
                    else
                    {
                        CombineMotion combineStopMotion = new CombineMotion(this, 1, motionsCombineSpawnStopMoveSquare);
                        motionsCombineSpawnMoveSquare.Add(combineStopMotion);
                    }
                    CombineMotion combinSquarePositionMotion = new CombineMotion(this, 1, motionsCombineSpawnMoveSquare);
                    motionsSpawnCombine.Add(combinSquarePositionMotion);
                }
            }
            CombineMotion combinMoveMotion = new CombineMotion(this, reproductionOrder, motionsSpawnCombine);

            return(combinMoveMotion);
        }
        public Dictionary <Transform, Vector3[]> GetRoutePositions(Transform[] enemies, POSITIONTYPE positionType, Vector3 finalWorldDestination, Vector3 actualPosition)
        {
            int amountOfPositionsToVisit = 3;
            Dictionary <Transform, Vector3[]> transformWithPositionToTween = new Dictionary <Transform, Vector3[]>();

            Vector3[] finalDestinationForEach   = GetPositions(finalWorldDestination, positionType);
            Vector3   pointOfExitFromActualTile = GetTileExitDirection(actualPosition, finalWorldDestination);

            pointOfExitFromActualTile = actualPosition + new Vector3(offsetPosition * pointOfExitFromActualTile.x, offsetPosition * pointOfExitFromActualTile.y, 0);

            // Position[0] = transformToPosition[i].position
            // Position[1] = El Borde por donde salga para ir hacia la unidad, entonces tengo que tener una funcion para saber para que lado estoy yendo
            //               Este borde va a ser igual para todas las unidades, asi que es una posicion que vamos a guardar al principio
            // Position[2] = finalDestinationForEach[n]
            for (int i = 0; i < enemies.Length; i++)
            {
                Vector3[] ListOfPositionsForDictionary = new Vector3[amountOfPositionsToVisit];

                ListOfPositionsForDictionary[0] = enemies[i].position;
                ListOfPositionsForDictionary[1] = pointOfExitFromActualTile;
                ListOfPositionsForDictionary[2] = finalDestinationForEach[i];

                transformWithPositionToTween.Add(enemies[i], ListOfPositionsForDictionary);
            }
            return(transformWithPositionToTween);
        }