コード例 #1
0
    override public GameObject Spawn(Map map, Vector2 location)
    {
        GameObject monster = base.Spawn(map, location);

        monster.AddComponent <Timer>();
        GameObject particles = Instantiate(damageParticles, monster.transform);
        GameObject healthBar = Instantiate(healthBarPrefab, monster.transform, false);

        healthBar.AddComponent <EnemyHealthBarManager>();

        Animator anim = monster.AddComponent <Animator>();

        anim.runtimeAnimatorController = animatorController;
        MovementAnimation moveAnim = monster.AddComponent <MovementAnimation>();

        particles.transform.localPosition = Vector3.back;
        monster.layer = LayerMask.NameToLayer("Enemy");

        MonsterObject obj = new MonsterObject(monster, CalcMaxHealth(map));

        this.entityObject = obj;
        obj.entityDropGen = entityDropGen;

        monster.GetComponent <EntityHealthManager>().entityObj = obj;

        return(monster);
    }
コード例 #2
0
 /// <summary>
 /// Get all of the references to the ghost's components.
 /// </summary>
 void getComponents()
 {
     animator          = GetComponent <Animator>();
     rb                = GetComponent <Rigidbody2D>();
     sr                = GetComponent <SpriteRenderer>();
     movementAnimation = GetComponent <MovementAnimation>();
 }
コード例 #3
0
    // Use this for initialization
    void Start()
    {
        instance = this;

        rb = gameObject.GetComponent <Rigidbody2D>();
        sr = gameObject.GetComponent <SpriteRenderer>();

        movementAnimation = GetComponent <MovementAnimation>();
    }
コード例 #4
0
    internal void StartCompletingAnimation(TileController objective)
    {
        Vector3 target   = objective.transform.localPosition - Vector3.up * 2;
        float   duration = PlayBoard.TURN_DURATION * 3;

        completingAnimation = gameObject.AddComponent <AnimationGroup>();
        completingAnimation.AddAnimation(ColorAnimation.CreateColorAnimation(Mesh, Color.clear, duration));
        completingAnimation.AddAnimation(objective.GetFillingAnimation(duration));
        completingAnimation.AddAnimation(MovementAnimation.CreateMovementAnimation(gameObject, target, duration));
        completingAnimation.StartAnimating();
    }
コード例 #5
0
ファイル: WinAnim.cs プロジェクト: LeSphax/PerspectiveShift
    // Use this for initialization
    void Start()
    {
        duration    = 1.0f;
        targetScale = transform.localScale * 4;
        Vector3           target           = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2, 10));
        MovementAnimation currentAnimation = MovementAnimation.CreateMovementAnimation(gameObject, target, duration);

        currentAnimation.StartAnimating();
        StartAnimating();
        //transform.LookAt(Camera.main.transform);
    }
コード例 #6
0
 public MagnetSwitchBehaviour()
 {
     //movementBehaviour = new IdleSwitchMovementBehaviour();
     animationVector          = new SwitchAnimationVector();
     currentMovementAnimation = new MovementAnimation();
     clickMovementAnimation   = new MovementAnimation();
     clickMovementAnimation.AddMovement(new IdleSwitchMovementBehaviour(new Vector2(1, 1)));
     clickMovementAnimation.AddMovement(new PressedSwitchBehaviour(animationVector.PressedScalingStartPoint,
                                                                   animationVector.PressedScalingEndPoint));
     clickMovementAnimation.AddMovement(new RetractingSwitchBehaviour(animationVector.RetractingScalingStartPoint,
                                                                      animationVector.RetractingScalingEndPoint));
     clickMovementAnimation.AddMovement(new RetractedSwitchMovementBehaviour(animationVector.RetractingScalingEndPoint));
 }
コード例 #7
0
    void Start()
    {
        _rb = GetComponent <Rigidbody>();
        if (_rb == null)
        {
            _rb = gameObject.AddComponent <Rigidbody>();
        }

        _animation   = GetComponent <MovementAnimation>();
        _speedSystem = GetComponent <SpeedSystem>();

        _direction    = Vector3.forward;
        _oldDirection = _direction;
    }
コード例 #8
0
        public void SpawnUnit(int PlayerIndex, UnitMap NewUnit, Vector3 SpawnPosition, Vector3 SpawnDestination)
        {
            NewUnit.Unit3D = new UnitMap3D(GameScreen.GraphicsDevice, Content.Load<Effect>("Shaders/Squad shader 3D"), NewUnit.ActiveUnit.SpriteMap, 1);
            NewUnit.ActiveUnit.Init();
            ListPlayer[PlayerIndex].ListUnit.Add(NewUnit);

            NewUnit.SetPosition(SpawnPosition);

            Vector3 FinalPosition;
            GetEmptyPosition(SpawnDestination, out FinalPosition);

            MovementAnimation.Add(NewUnit.X, NewUnit.Y, NewUnit);

            NewUnit.SetPosition(FinalPosition);
        }
コード例 #9
0
    public void Init()
    {
        player = new GameObject("player");
        player.AddComponent <SpriteRenderer>();
        rigidbody = player.AddComponent <Rigidbody2D>();
        rigidbody.gravityScale   = 0f;
        rigidbody.angularDrag    = 0f;
        rigidbody.freezeRotation = true;

        anim = player.AddComponent <Animator>();
        anim.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("Animations/Player");
        playerAnimationController      = anim.runtimeAnimatorController;
        //Debug.Log("RuntimeAnimController: " + anim.runtimeAnimatorController.ToString());
        MovementAnimation moveAnim = player.AddComponent <MovementAnimation>();
    }
コード例 #10
0
    public void PlayMovementAnimation(MovementAnimation movementAnimation)
    {
        switch (movementAnimation)
        {
        case MovementAnimation.Idle:
            animator.ResetTrigger(runTrigger);
            animator.SetTrigger(idleTrigger);
            break;

        case MovementAnimation.Run:
            animator.ResetTrigger(idleTrigger);
            animator.SetTrigger(runTrigger);
            break;
        }
    }
コード例 #11
0
ファイル: Player.cs プロジェクト: smwolfskill/Lumiere
    override public GameObject Spawn(Map map, Vector2 location)
    {
        GameObject player = base.Spawn(map, location);

        player.tag   = "Player";
        player.layer = LayerMask.NameToLayer("Player");

        Animator anim = player.AddComponent <Animator>();

        anim.runtimeAnimatorController = animatorController;
        MovementAnimation moveAnim = player.AddComponent <MovementAnimation>();

        AttackAnimationObject = CreateAttackAnimGameObject();
        AttackAnimationObject.transform.SetParent(player.transform);
        AttackAnimationObject.transform.localPosition = Vector3.zero;

        EntityActionManager actionManager = player.AddComponent <EntityActionManager>();

        actionManager.entity = this;
        PlayerObject entityObj = new PlayerObject(player, maxHealth);

        this.entityObject       = entityObj;
        entityObj.entityDropGen = entityDropGen;
        EntityHealthManager healthManagerTest = player.GetComponent <EntityHealthManager>();

        if (healthManagerTest == null)
        {
            EntityHealthManager healthManager = player.AddComponent <EntityHealthManager>();
            healthManager.entityObj = entityObj;
        }
        else
        {
            healthManagerTest.entityObj = this.entityObject;
        }
        player.AddComponent <EntityObjectManager>().entityObject = entityObj;


        return(player);
    }
コード例 #12
0
    void createMovementAnimation(int toX, int toY)
    {
        // Ativando esse boolean que indica que a orbe esta no meio de uma animaçao
        isAnimating = true;

        // Calculando a duraçao da animaçao baseado na distancia entre a posiçao inicial e a final em relaçao a constante moveSpeed
        float duration = Mathf.Abs((posX - toX) + (posY - toY)) * moveSpeed;

        // Criando e exectando a animaçao de movimento da orbe
        boardNodeAnimation = new MovementAnimation(this, new Vector2(toX + Board.kBoardOffSetX, toY + Board.kBoardOffSetY), duration);

        // Setando a posiçao em que a orbe estava na matriz para nula
        getBoard().boardMatrix[posX, posY] = null;

        // Setando a posiçao final da orbe na matriz para ela mesma
        getBoard().boardMatrix[toX, toY] = this;

        // Atualizando as variaveis que controlam a posiçao atual da orbe
        posX = toX;
        posY = toY;

        // Tocando o efeito sonoro da orbe deslizando pelo gelo
        PlaySound("Slide");
    }
コード例 #13
0
        /// <summary>
        /// Try to attack with Weapon 1.
        /// </summary>
        /// <returns>Returns true if success.</returns>
        public bool AIAttackWithWeapon1(UnitConquest ActiveUnit)
        {
            int    PosX         = (int)ActiveUnit.X;
            int    PosY         = (int)ActiveUnit.Y;
            Attack ActiveWeapon = ActiveUnit.ListAttack[0];
            List <Tuple <int, int> > ListDefendingSquad = CanSquadAttackWeapon1(PosX, PosY, ActivePlayerIndex, ActiveUnit.FullName, ActiveUnit.ListAttack[1]);

            if (!ActiveUnit.CanMove && !((ActiveWeapon.Sec & WeaponSecondaryProperty.PostMovement) == WeaponSecondaryProperty.PostMovement || ActiveUnit.Boosts.PostMovementModifier.Attack))
            {
                return(false);
            }

            //Define the minimum and maximum value of the attack range.
            int   MinRange = ActiveWeapon.RangeMinimum;
            int   MaxRange = ActiveWeapon.RangeMaximum;
            float Distance;

            if (MaxRange > 1)
            {
                MaxRange += ActiveUnit.Boosts.RangeModifier;
            }

            #region Can attack

            if (ListDefendingSquad.Count > 0)
            {
                UnitConquest TargetSquad = ListPlayer[ListDefendingSquad[0].Item1].ListUnit[ListDefendingSquad[0].Item2];

                //Prepare the Cursor to move.
                CursorPosition.X = ActiveUnit.X;
                CursorPosition.Y = ActiveUnit.Y;
                GetAttackChoice(ActiveUnit, ActiveUnit.Position);
                ActiveUnit.BattleDefenseChoice = Unit.BattleDefenseChoices.Attack;

                GetAttackDamageWithWeapon1(ActiveUnit, TargetSquad, ActiveUnit.HP);
                return(true);//Exit the weapon loop.
            }

            #endregion

            #region Can't attack directly

            //If it's a post-movement weapon or you can still move.
            else if (ActiveUnit.CanMove && ((ActiveWeapon.Sec & WeaponSecondaryProperty.PostMovement) == WeaponSecondaryProperty.PostMovement || ActiveUnit.Boosts.PostMovementModifier.Attack))
            {//check if there is an enemy too close to be attacked but that could be attacked after moving.
                for (int P = 0; P < ListPlayer.Count; P++)
                {
                    //If the player is from the same team as the current player or is dead, skip it.
                    if (ListPlayer[P].Team == ListPlayer[ActivePlayerIndex].Team ||
                        !ListPlayer[P].IsAlive)
                    {
                        continue;
                    }
                    for (int TargetSelect = 0; TargetSelect < ListPlayer[P].ListUnit.Count; TargetSelect++)
                    {
                        UnitConquest TargetSquad = ListPlayer[P].ListUnit[TargetSelect];
                        Distance = Math.Abs(PosX - TargetSquad.X) + Math.Abs(PosY - TargetSquad.Y);
                        //Check if you can attack it if you moved.
                        if (Distance >= MinRange - GetSquadMaxMovement(ActiveUnit) && Distance <= MaxRange + GetSquadMaxMovement(ActiveUnit))
                        {
                            ListDefendingSquad.Add(new Tuple <int, int>(P, TargetSelect));
                        }
                    }
                }
                //If something was found.
                if (ListDefendingSquad.Count > 0)
                {
                    int RandomNumber = RandomHelper.Next(ListDefendingSquad.Count);
                    //Select a target.
                    UnitConquest TargetSquad  = ListPlayer[ListDefendingSquad[RandomNumber].Item1].ListUnit[ListDefendingSquad[RandomNumber].Item2];
                    float        DistanceUnit = Math.Abs(PosX - TargetSquad.X) + Math.Abs(PosY - TargetSquad.Y);
                    //Move to be in range.
                    List <Vector3> ListRealChoice = new List <Vector3>(GetMVChoice(ActiveUnit));
                    for (int M = 0; M < ListRealChoice.Count; M++)
                    {//Remove every MV that would make it impossible to attack.
                        Distance = Math.Abs(ListRealChoice[M].X - TargetSquad.X) + Math.Abs(ListRealChoice[M].Y - TargetSquad.Y);
                        //Remove every MV that would bring the Unit too close to use its weapon.
                        if (DistanceUnit <= MinRange)
                        {
                            if (Distance <= MinRange)
                            {
                                ListRealChoice.RemoveAt(M--);
                            }
                        }
                        //Check if you can attack it if you moved.
                        else if (Distance < MinRange || Distance > MaxRange)
                        {
                            ListRealChoice.RemoveAt(M--);
                        }
                    }
                    //Must find a spot to move if got there, just to make sure it won't crash in case of logic error.
                    if (ListRealChoice.Count != 0)
                    {
                        int Choice = RandomHelper.Next(ListRealChoice.Count);

                        //Movement initialisation.
                        MovementAnimation.Add(ActiveUnit.X, ActiveUnit.Y, ActiveUnit.Components);

                        //Prepare the Cursor to move.
                        CursorPosition.X = ListRealChoice[Choice].X;
                        CursorPosition.Y = ListRealChoice[Choice].Y;
                        ActiveUnit.SetPosition(CursorPosition);
                        ActiveUnit.SetPosition(ListRealChoice[Choice]);

                        FinalizeMovement(ActiveUnit);
                    }
                    else
                    {
                        //Something is blocking the path.
                        ActiveUnit.EndTurn();
                    }
                    //Unit should be in attack range next time the AI is called.
                    return(true);//Exit the weapon loop.
                }
            }

            #endregion

            return(false);//Can't attack at all.
        }
コード例 #14
0
 // Use this for initialization
 void Start()
 {
     pd = GetComponent <PlayableDirector>();
     movementAnimation = this;
     isAnimating       = false;
 }