Example #1
0
        public Motion CombineMoveMotion(Vector3 actualPosition, Vector3 endPosition, GameObject[] enemies)
        {
            UnitMovePositioner movePositioner = new UnitMovePositioner(4f);
            Dictionary <GameObject, Vector3[]> enmiesAndPathToMove = movePositioner.GetRoutePositions(enemies, movePositioner.GetPositionType(enemies.Length), endPosition, actualPosition);
            List <Motion> motionsCombineMove = new List <Motion>();

            if (GameSoundManager.Instance != null)
            {
                if (GameSoundManager.Instance.audioSource != null)
                {
                    Motion motionMoveSound = new SoundMotion(this, 1, GameSoundManager.Instance.audioSource, GameSoundManager.Instance.audioClips[4], false, true);
                    motionsCombineMove.Add(motionMoveSound);
                }
            }

            int index = 0;

            foreach (KeyValuePair <GameObject, Vector3[]> entry in enmiesAndPathToMove)
            {
                AnimatedMotion motionMove = new MoveMotion(this, entry.Key.GetComponent <Animator>(), 1);
                motionsCombineMove.Add(motionMove);

                List <Motion> extraMotionsCombineStopMove = new List <Motion>();
                Motion        motionTweenMove             = new MovePathTweenMotion(this, entry.Key.transform, 1, entry.Value);
                Motion        motionIdlle = new IdlleMotion(this, entry.Key.GetComponent <Animator>(), 2, true);
                extraMotionsCombineStopMove.Add(motionTweenMove);
                extraMotionsCombineStopMove.Add(motionIdlle);

                // esto solo lo hago para detener el sonido de los pasos
                if (enmiesAndPathToMove.Count - 1 == index)
                {
                    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 extraCombineMoveStopMotion = new CombineMotion(this, 1, extraMotionsCombineStopMove, configurables);
                    motionsCombineMove.Add(extraCombineMoveStopMotion);
                }
                else
                {
                    CombineMotion extraCombineMoveStopMotion = new CombineMotion(this, 1, extraMotionsCombineStopMove);
                    motionsCombineMove.Add(extraCombineMoveStopMotion);
                }

                index++;
            }

            CombineMotion combinMoveMotion = new CombineMotion(this, 1, motionsCombineMove);

            return(combinMoveMotion);
        }
Example #2
0
        public Motion MoveMotion(GameObject goKimbok, Vector3 endPosition)
        {
            List <Motion> motionsMove = new List <Motion>();
            Animator      animator    = goKimbok.GetComponent <Animator>();
            Motion        motionMove  = new MoveMotion(this, animator, 1);

            motionsMove.Add(motionMove);

            List <Configurable> configurables = new List <Configurable>();

            if (GameSoundManager.Instance != null)
            {
                if (GameSoundManager.Instance.audioSource != null)
                {
                    Motion motionMoveSound = new SoundMotion(this, 1, GameSoundManager.Instance.audioSource, GameSoundManager.Instance.audioClips[4], false, true);
                    motionsMove.Add(motionMoveSound);
                    AudioSourceGenericContainer audioContainer = new AudioSourceGenericContainer(GameSoundManager.Instance.audioSource);
                    StopSoundConfigureAnimotion <AudioSourceGenericContainer, Transform> stopSoundConfigureAnimotion =
                        new StopSoundConfigureAnimotion <AudioSourceGenericContainer, Transform>(audioContainer, 2);
                    configurables.Add(stopSoundConfigureAnimotion);
                }
            }

            List <Motion> motionsStopMove = new List <Motion>();

            Motion motionTweenMove = new MoveTweenMotion(this, goKimbok.transform, 1, endPosition, 1);
            Motion motionIdlle     = new IdlleMotion(this, animator, 2, true);

            motionsStopMove.Add(motionTweenMove);
            motionsStopMove.Add(motionIdlle);

            CombineMotion combineStopMotion = new CombineMotion(this, 1, motionsStopMove, configurables);

            motionsMove.Add(combineStopMotion);

            CombineMotion combinMoveMotion = new CombineMotion(this, 1, motionsMove);

            return(combinMoveMotion);
        }
        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 Motion MoveToSquarePosition(List <GameObject> kimbokos, Vector3 actualPosition)
        {
            List <Motion>      motionsSpawnCombine = new List <Motion>();
            UnitMovePositioner movePositioner      = new UnitMovePositioner(4f);

            // 2 - DESPUES ME DEBERIA FIJAR SI TENGO ENEMIGOS EN LA QUE SELECCIONE, Y SI TENGO DEBERIA AGREGAR EL COMANDO DE REPOSICIONARLOS
            if (kimbokos.Count > 0)
            {
                // AHORA TENGO QUE GENERAR EL CUADRADO DE POSICIONES PARA CADA UNA
                Vector3[] squarePositions = movePositioner.GetPositions(actualPosition, POSITIONTYPE.SQUARE);

                // 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++)
                {
                    Animator animatorAux = kimbokos[i].GetComponent <Animator>();


                    List <Motion> motionsCombineSpawnMoveSquare = new List <Motion>();
                    Motion        motionMove = new MoveMotion(this, animatorAux, 1);
                    motionsCombineSpawnMoveSquare.Add(motionMove);

                    List <Motion> motionsCombineSpawnStopMoveSquare = new List <Motion>();
                    Motion        motionTwMove = new MoveTweenMotion(this, kimbokos[i].transform, 1, squarePositions[i], 1);
                    Motion        motionIdlle  = new IdlleMotion(this, animatorAux, 2, true);
                    motionsCombineSpawnStopMoveSquare.Add(motionTwMove);
                    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 repositionInSquareMotion = new CombineMotion(this, 1, motionsSpawnCombine);

            return(repositionInSquareMotion);
        }