Ejemplo n.º 1
0
 public void SwordSwish(SmoothMoves.UserTriggerEvent triggerEvent)
 {
     if (triggerEvent.boneName == "Weapon")
     {
         swishSound.Play();
     }
 }
Ejemplo n.º 2
0
    /// <summary>
    /// SmoothMove UserTrigger(當播完動畫後開啟偵測模式)
    /// </summary>
    /// <param name="triggerEvent"></param>
    public void AutoDestroy(SmoothMoves.UserTriggerEvent triggerEvent)
    {
        //開啟偵測模式
        switch (triggerEvent.animationName)
        {
            case "構圖":
                this.changeStage = GameManager.DrawStage.構圖;
                this.checkSkip = true;
                break;

            case "明暗":
                this.changeStage = GameManager.DrawStage.明暗;
                this.checkSkip = true;
                break;

            case "設色":
                this.changeStage = GameManager.DrawStage.設色;
                this.checkSkip = true;
                break;

            case "淡化":
                this.changeStage = GameManager.DrawStage.淡化;
                this.checkSkip = true;
                break;

            case "光源":
                this.changeStage = GameManager.DrawStage.光源;
                this.checkSkip = true;
                break;
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// 綁在敵人武器上的Collider,觸發攻擊判定(近距離攻擊使用)
    /// </summary>
    /// <param name="triggerEvent">觸發相關資訊</param>
    public void RootHit(SmoothMoves.ColliderTriggerEvent triggerEvent)
    {
        //確認是由"weapon"碰撞的collider
        if (triggerEvent.boneName.Contains("TreeRoot") && triggerEvent.triggerType == SmoothMoves.ColliderTriggerEvent.TRIGGER_TYPE.Enter)
        {
            if (((1 << triggerEvent.otherCollider.gameObject.layer) & this.AttackLayer.value) > 0)
            {
                //tag = MainBody
                if (triggerEvent.otherCollider.tag.CompareTo("MainBody") == 0)
                {
                    triggerEvent.otherCollider.GetComponent<RolePropertyInfo>().DecreaseLife(this.Damage);

                    //創建 斬擊特效BoneAnimation
                    SmoothMoves.BoneAnimation obj = (SmoothMoves.BoneAnimation)Instantiate(GameManager.script.EffectAnimationObject);
                    //設定動畫播放中心點
                    Vector3 expPos = triggerEvent.otherColliderClosestPointToBone;
                    expPos.z = triggerEvent.otherCollider.gameObject.transform.position.z - 1;
                    obj.mLocalTransform.position = expPos;
                    obj.playAutomatically = false;
                    //隨機撥放 1 或 2 動畫片段
                    if (Random.Range(0, 2) == 0)
                        obj.Play("撞擊特效01");
                    else
                        obj.Play("撞擊特效02");
                }
            }
        }
    }
Ejemplo n.º 4
0
 /// <summary>
 /// User Trigger delegate that is fired from the game over animation
 /// </summary>
 /// <param name="utEvent">Event sent from the animation</param>
 public void GameOver_UserTrigger(SmoothMoves.UserTriggerEvent utEvent)
 {
     // done event was sent
     if (utEvent.tag == "Done")
     {
         gameManager.State = GameManager.STATE.WaitingForInput;
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// User Trigger delegate that is fired from the instructions animation
 /// </summary>
 /// <param name="utEvent">Event sent from the animation</param>
 public void Instructions_UserTrigger(SmoothMoves.UserTriggerEvent utEvent)
 {
     if (utEvent.tag == "Done")
     {
         instructionsAnimation.gameObject.active = false;
         InstructionsDismissed = true;
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// SmoothMove UserTrigger(當播完動畫後刪除自己)
 /// </summary>
 /// <param name="triggerEvent"></param>
 public void FlowerCloseDestroy(SmoothMoves.UserTriggerEvent triggerEvent)
 {
     //花閉合的動畫播完後,才可刪除
     if (triggerEvent.animationName.CompareTo("FlowerClose") == 0)
     {
         BossController_TreeElder.script.currentOpenFlowerCount--;
         Destroy(this.gameObject);
     }
 }
Ejemplo n.º 7
0
    public void SwordHit(SmoothMoves.ColliderTriggerEvent triggerEvent)
    {
        if (triggerEvent.boneName == "Weapon" && triggerEvent.triggerType == SmoothMoves.ColliderTriggerEvent.TRIGGER_TYPE.Enter)
        {
            hitSound.Play();

            sparks.mLocalTransform.position = triggerEvent.otherColliderClosestPointToBone;
            sparks.Play("Hit");
        }
    }
Ejemplo n.º 8
0
 /// <summary>
 /// UserTrigger,觸發判定
 /// </summary>
 /// <param name="triggerEvent">觸發相關資訊</param>
 public void UserTrigger(SmoothMoves.UserTriggerEvent triggerEvent)
 {
     //確認是由"登場"動畫觸發的UserTrigger
     if (triggerEvent.animationName == "登場" & triggerEvent.boneName == "ChangeLayer")
     {
         //改變魔王Layer,更改為Boss Layer,啟動AI,角色開始攻擊
         this.gameObject.layer = LayerMask.NameToLayer("Boss");
         this.ActionTimer.ChangeTimerState(true);
     }
 }
Ejemplo n.º 9
0
 /// <summary>
 /// SmoothMove UserTrigger(當播完死亡動畫後刪除自己)
 /// </summary>
 /// <param name="triggerEvent"></param>
 public void DeadDestroy(SmoothMoves.UserTriggerEvent triggerEvent)
 {
     //確認已進入死亡狀態且撥放死亡動畫後,才可刪除
     if (this.isDead && triggerEvent.animationName.CompareTo("defeat") == 0)
     {
         //移除物件的同時,移除註冊於GameManager AllBoneAnimationList中的資訊
         if (GameManager.script.AllBoneAnimationList.ContainsKey(this.boneAnimation))
             GameManager.script.AllBoneAnimationList.Remove(this.boneAnimation);
         Destroy(this.gameObject);
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// User Trigger delegate that is fired from the instructions animation
 /// </summary>
 /// <param name="utEvent">Event sent from the animation</param>
 public void Instructions_UserTrigger(SmoothMoves.UserTriggerEvent utEvent)
 {
     if (utEvent.tag == "Done")
     {
     #if UNITY_3_5
         instructionsAnimation.gameObject.active = false;
     #else
         instructionsAnimation.gameObject.SetActive(false);
     #endif
         InstructionsDismissed = true;
     }
 }
Ejemplo n.º 11
0
    private void ChangeAnimation(SmoothMoves.BoneAnimation newAnimation)
    {
        newAnimation.transform.position = transform.position;
        newAnimation.transform.parent = transform;

        if (animationData != null) {
            Utils.SetActiveRecursively(animationData.gameObject, false);
        }

        animationData = newAnimation;
        Utils.SetActiveRecursively(animationData.gameObject, true);
    }
Ejemplo n.º 12
0
    /// <summary>
    /// This function will be called whenever a collider is processed by the knight. We assign this 
    /// function in the Awake of this example.
    /// </summary>
    /// <param name='triggerEvent'>
    /// The event to process
    /// </param>
    public void ColliderTrigger(SmoothMoves.ColliderTriggerEvent triggerEvent)
    {
        // filter down the event to only capture when something hits the Weapon bone on the ENTER event type
        if (triggerEvent.boneName == "Weapon" && triggerEvent.triggerType == SmoothMoves.ColliderTriggerEvent.TRIGGER_TYPE.Enter)
        {
            // play the hit sound since this was a collision
            hitSound.Play();

            // move sparks to the nearest location of the hit point and then play the sparks animation
            sparks.mLocalTransform.position = triggerEvent.otherColliderClosestPointToBone;
            sparks.Play("Hit");
        }
    }
Ejemplo n.º 13
0
    /// <summary>
    /// 綁在敵人武器上的Collider,觸發攻擊判定(近距離攻擊使用)
    /// </summary>
    /// <param name="triggerEvent">觸發相關資訊</param>
    public void WeaponHit(SmoothMoves.ColliderTriggerEvent triggerEvent)
    {
        //確認是由"weapon"碰撞的collider
        if (triggerEvent.boneName == "weapon" && triggerEvent.triggerType == SmoothMoves.ColliderTriggerEvent.TRIGGER_TYPE.Enter)
        {
            if (((1 << triggerEvent.otherCollider.gameObject.layer) & this.AttackLayer.value) > 0)
            {
                //tag = MainBody
                if (triggerEvent.otherCollider.tag.CompareTo("MainBody") == 0)
                {
                    triggerEvent.otherCollider.GetComponent<RolePropertyInfo>().DecreaseLife(this.enemyInfo.damage);

                    //創建 斬擊特效BoneAnimation
                    SmoothMoves.BoneAnimation obj = (SmoothMoves.BoneAnimation)Instantiate(GameManager.script.EffectAnimationObject);

                    //設定動畫播放中心點
                    Vector3 expPos = triggerEvent.otherColliderClosestPointToBone;
                    expPos.z = triggerEvent.otherCollider.gameObject.transform.position.z - 1;
                    obj.mLocalTransform.position = expPos;
                    obj.playAutomatically = false;

                    //不同種類的怪物產生不同的攻擊特效
                    switch (this.enemyInfo.Enemy)
                    {
                        case GameDefinition.Enemy.史萊姆:
                        case GameDefinition.Enemy.火焰史萊姆:
                        case GameDefinition.Enemy.硬化史萊姆:
                        case GameDefinition.Enemy.中型史萊姆:
                        case GameDefinition.Enemy.中型火焰史萊姆:
                        case GameDefinition.Enemy.中型硬化史萊姆:
                            //隨機撥放 1 或 2 動畫片段
                            if (Random.Range(0, 2) == 0)
                                obj.Play("撞擊特效01");
                            else
                                obj.Play("撞擊特效02");
                            break;

                        default:
                            //隨機撥放 1 或 2 動畫片段
                            if (Random.Range(0, 2) == 0)
                                obj.Play("斬擊特效01");
                            else
                                obj.Play("斬擊特效02");
                            break;
                    }
                }
            }
        }
    }
Ejemplo n.º 14
0
    /// <summary>
    /// 綁在敵人武器上的UserTrigger,觸發攻擊判定(遠距離攻擊使用)
    /// </summary>
    /// <param name="triggerEvent">觸發相關資訊</param>
    public void ShootEvent(SmoothMoves.UserTriggerEvent triggerEvent)
    {
        //確認是由"weapon"觸發的UserTrigger
        if (triggerEvent.boneName == "weapon")
        {
            //產生射擊物件
            GameObject obj = (GameObject)Instantiate(this.ShootObject, this.transform.position - new Vector3(0, 0, 0.1f), this.ShootObject.transform.rotation);

            //設定物件的parent 、 layer 、 Damage
            obj.layer = LayerMask.NameToLayer("ShootObject");
            obj.transform.parent = GameObject.Find("UselessObjectCollection").transform;
            if (obj.GetComponent<ShootObjectInfo_Once>())
                obj.GetComponent<ShootObjectInfo_Once>().Damage = this.enemyInfo.damage;
            else if (obj.GetComponent<ShootObjectInfo_Through>())
                obj.GetComponent<ShootObjectInfo_Through>().Damage = this.enemyInfo.damage;
        }
    }
Ejemplo n.º 15
0
    /// <summary>
    /// 綁在角色武器上的UserTrigger,觸發攻擊判定(遠距離攻擊使用)
    /// </summary>
    /// <param name="triggerEvent">觸發相關資訊</param>
    public void ShootEvent(SmoothMoves.UserTriggerEvent triggerEvent)
    {
        //遠距離角色一般攻擊觸發的UserTrigger
        if (triggerEvent.boneName == "weapon" && triggerEvent.animationName == "attack")
        {
            //產生射擊物件
            GameObject obj = (GameObject)Instantiate(this.ShootObject, this.transform.position - new Vector3(0, 0, 0.1f), this.ShootObject.transform.rotation);

            //設定物件的parent 、 layer 、 Damage
            obj.layer = LayerMask.NameToLayer("ShootObject");
            obj.transform.parent = GameObject.Find("UselessObjectCollection").transform;
            if (obj.GetComponent<ShootObjectInfo_Once>())
                obj.GetComponent<ShootObjectInfo_Once>().Damage = Mathf.FloorToInt(this.roleInfo.damage * (1 + this.roleInfo.AttackRatioAdd * this.roleInfo.AttackLV));
            else if (obj.GetComponent<ShootObjectInfo_Through>())
                obj.GetComponent<ShootObjectInfo_Through>().Damage = Mathf.FloorToInt(this.roleInfo.damage * (1 + this.roleInfo.AttackRatioAdd * this.roleInfo.AttackLV));
        }

        //角色釋放絕招觸發的UserTrigger
        if (triggerEvent.boneName == "weapon" && triggerEvent.animationName == "絕招01")
        {
            if (triggerEvent.normalizedTime == 1)   //動畫最後一Frame
            {
                this.isUsingSkill = false;
                GameManager.script.ChangeButtonUIObject.SetActive(true);    //恢復角色交換功能
                GameManager.script.ResumeAllBoneAnimation();                //恢復所有註冊的BoneAnimation
                if (GameManager.script.CurrentBossObject != null)
                {
                    iTween.Resume(GameManager.script.CurrentBossObject);     //恢復當前魔王的iTween
                    if (GameManager.script.CurrentBossObject.transform.parent.GetComponent<EnemyCreatePoint>())
                        GameManager.script.CurrentBossObject.transform.parent.GetComponent<EnemyCreatePoint>().ResumeCreate();  //恢復魔王點生怪狀態
                }
                else
                    BackgroundController.script.SetRunBackgroundState(true);    //恢復地圖移動
                foreach (MoveController script in GameObject.FindObjectsOfType(typeof(MoveController))) //恢復所有物件的移動功能
                    script.isRunning = true;
            }
            else
            {
                this.CheckRoleUniqueSkill(this.roleInfo.Role);
            }
        }
    }
Ejemplo n.º 16
0
    /// <summary>
    /// Checks animation tag.
    /// </summary>
    /// <param name='_userTriggerEvent'>
    /// _user trigger event.
    /// </param>
    void CheckMyTag(SmoothMoves.UserTriggerEvent _userTriggerEvent)
    {
        //	Debug.Log("UserTriggerEvent -> tag: " + _userTriggerEvent.tag);

        if (_userTriggerEvent.tag == "end_of_idle") {
            if (Random.Range(0, 100) > 75) {
                PlayRandomIdle();
            } else {
                TheGoodGuy_Ref.GetComponent<Animation>().animation.Play("Idle_Clip_1");
            }
        }

        if (_userTriggerEvent.tag == "start_walking") {
            TheGoodGuy_Ref.GetComponent<Animation>().animation.Play("Walk_2");
        }

        if (_userTriggerEvent.tag == "stop_walking") {
            TheGoodGuy_Ref.GetComponent<Animation>().animation.Play("Idle_Clip_1");
        }
    }
Ejemplo n.º 17
0
    /// <summary>
    /// 動畫事件
    /// </summary>
    /// <param name="triggerEvent">觸發相關資訊</param>
    public void AnimationEventFunction(SmoothMoves.UserTriggerEvent triggerEvent)
    {
        //處理音效控制
        if (triggerEvent.boneName == "城堡民宅")
            Instantiate(this.城堡民宅_音效);
        else if (triggerEvent.boneName == "大史萊姆落下")
            Instantiate(this.大史萊姆落下_音效);
        else if (triggerEvent.boneName == "小史萊姆落下")
            Instantiate(this.小史萊姆落下_音效);
        else if (triggerEvent.boneName == "邪氣降臨")
            Instantiate(this.邪氣降臨_音效);
        else if (triggerEvent.boneName == "釋放邪氣")
            Instantiate(this.釋放邪氣_音效);
        else if (triggerEvent.boneName == "魔王城")
            Instantiate(this.魔王城_音效);

        //結尾
        if (triggerEvent.normalizedTime == 1)
        {
            MUI_LoadSceneTransitionsEffect.script.LoadScene("LevelSelectScene", 0);
        }
    }
Ejemplo n.º 18
0
    /// <summary>
    /// User trigger delegate called when the animation sends a user trigger
    /// </summary>
    /// <param name="userTriggerEvent">User trigger event passed by the animation</param>
    public void UserTrigger(SmoothMoves.UserTriggerEvent userTriggerEvent)
    {
        // determine what user trigger was fired

        if (userTriggerEvent.tag == "play swish")
        {
            // play the swish sound
            gameManager.soundFXManager.Play("swish");
        }
        else if (userTriggerEvent.tag == "turn on colors")
        {
            // set the color processing on.
            // this saves us from having to constantly process colors (costly)
            // instead only processing when necessary
            boneAnimation.updateColors = true;
        }
        else if (userTriggerEvent.tag == "turn off colors")
        {
            // set the color processing off
            // this saves us from having to constantly process colors (costly)
            // instead only processing when necessary
            boneAnimation.updateColors = false;
        }
        else if (userTriggerEvent.tag == "Done Picking Up Weapon")
        {
            // if we are done picking up the weapon, then set the state back to standing
            State = STATE.Standing;
        }
    }
Ejemplo n.º 19
0
 /// <summary>
 /// This function will be called whenever a user trigger is encountered in the animation. We assign this
 /// function in the Awake of this example.
 /// </summary>
 /// <param name='triggerEvent'>
 /// The event to process
 /// </param>
 public void UserTrigger(SmoothMoves.UserTriggerEvent triggerEvent)
 {
     // filter down the events to only look at user triggers on the Weapon bone
     if (triggerEvent.boneName == "Weapon")
     {
         // play the swish sound for this event
         swishSound.Play();
     }
 }
Ejemplo n.º 20
0
 /// <summary>
 /// 註冊BoneAnimation(角色、敵人必須註冊,方便系統控制)
 /// </summary>
 /// <param name="boneAnimation">角色/敵人的BoneAnimation</param>
 public void RegisterBoneAnimation(SmoothMoves.BoneAnimation boneAnimation)
 {
     this.AllBoneAnimationList.Add(boneAnimation, true);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// SmoothMove UserTrigger(當播完消失動畫後刪除自己)
 /// </summary>
 /// <param name="triggerEvent"></param>
 void DisappearDestroy(SmoothMoves.UserTriggerEvent triggerEvent)
 {
     //確認已進入消失狀態且撥放消失動畫後,才可刪除
     if (this.isDisappear && (triggerEvent.animationName.CompareTo("correct") == 0 || triggerEvent.animationName.CompareTo("fail") == 0))
         Destroy(this.gameObject);
 }
Ejemplo n.º 22
0
 public bool Fire(Action action, SmoothMoves.UserTriggerEvent triggerEvent)
 {
     return Traverse(action, triggerEvent);
 }
Ejemplo n.º 23
0
 /// <summary>
 /// SmoothMove UserTrigger(當播完動畫後刪除自己)
 /// </summary>
 /// <param name="triggerEvent"></param>
 public void ExplosionDestroy(SmoothMoves.UserTriggerEvent triggerEvent)
 {
     //確認已進入爆炸狀態且爆炸死亡動畫後,才可刪除
     if (this.isExplosion && triggerEvent.animationName.CompareTo("explosion") == 0)
         Destroy(this.gameObject);
 }
Ejemplo n.º 24
0
    /// <summary>
    /// 綁在角色武器上的Collider,觸發攻擊判定(近距離攻擊使用)
    /// </summary>
    /// <param name="triggerEvent">觸發相關資訊</param>
    public void WeaponHit(SmoothMoves.ColliderTriggerEvent triggerEvent)
    {
        //確認是由"weapon"碰撞的collider
        if (triggerEvent.boneName == "weapon" && triggerEvent.triggerType == SmoothMoves.ColliderTriggerEvent.TRIGGER_TYPE.Enter)
        {
            //tag = MainBody  (物件主體)
            if (triggerEvent.otherCollider.tag.CompareTo("MainBody") == 0)
            {
                string layerName = LayerMask.LayerToName(triggerEvent.otherCollider.gameObject.layer);
                bool isCheck = false;

                //判別物件為何?  敵人、障礙物、魔王有不同的處理
                if (layerName.CompareTo("Enemy") == 0)
                {
                    triggerEvent.otherCollider.GetComponent<EnemyPropertyInfo>().DecreaseLife(Mathf.FloorToInt(this.roleInfo.damage * (1 + this.roleInfo.AttackRatioAdd * this.roleInfo.AttackLV)));
                    isCheck = true;
                }
                else if (layerName.CompareTo("Boss") == 0)
                {
                    triggerEvent.otherCollider.GetComponent<BossPropertyInfo>().DecreaseLife(Mathf.FloorToInt(this.roleInfo.damage * (1 + this.roleInfo.AttackRatioAdd * this.roleInfo.AttackLV)));
                    isCheck = true;
                }
                else if (layerName.CompareTo("Obstacle") == 0)
                {
                    triggerEvent.otherCollider.GetComponent<ObstaclePropertyInfo>().CheckObstacle(true);
                    isCheck = true;
                }

                if (isCheck)
                {
                    //創建 斬擊特效BoneAnimation
                    SmoothMoves.BoneAnimation obj = (SmoothMoves.BoneAnimation)Instantiate(GameManager.script.EffectAnimationObject);
                    //設定動畫播放中心點
                    Vector3 expPos = triggerEvent.otherColliderClosestPointToBone;
                    expPos.z = triggerEvent.otherCollider.gameObject.transform.position.z - 1;
                    obj.mLocalTransform.position = expPos;
                    obj.playAutomatically = false;
                    //隨機撥放 1 或 2 動畫片段
                    if (Random.Range(0, 2) == 0)
                        obj.Play("斬擊特效01");
                    else
                        obj.Play("斬擊特效02");
                }
            }
        }
    }
Ejemplo n.º 25
0
 /// <summary>
 /// User Trigger delegate that is fired from the new weapon available animation
 /// </summary>
 /// <param name="utEvent">Event sent from the animation</param>
 public void NewWeaponAvailable_UserTrigger(SmoothMoves.UserTriggerEvent utEvent)
 {
     if (utEvent.tag == "Done")
     {
         newWeaponAvailableAnimation.gameObject.active = false;
     }
 }
Ejemplo n.º 26
0
 /// <summary>
 /// SmoothMove UserTrigger(當播完動畫後刪除自己)
 /// </summary>
 /// <param name="triggerEvent"></param>
 public void AttackDestroy(SmoothMoves.UserTriggerEvent triggerEvent)
 {
     //攻擊動畫後,才可刪除
     if (triggerEvent.animationName.CompareTo("小樹根") == 0 || triggerEvent.animationName.CompareTo("大樹根") == 0)
         Destroy(this.gameObject);
 }
Ejemplo n.º 27
0
    /// <summary>
    /// 暫停所有註冊的BoneAnimation (去除參數的BoneAnimation)
    /// </summary>
    /// <param name="dontStopAnimation">不暫停的BoneAnimation</param>
    public void StopAllBoneAnimation(SmoothMoves.BoneAnimation dontStopAnimation = null)
    {
        lock (this.AllBoneAnimationList)
        {
            //從List 複製到local arrays
            SmoothMoves.BoneAnimation[] allAnimations = new SmoothMoves.BoneAnimation[this.AllBoneAnimationList.Keys.Count];
            this.AllBoneAnimationList.Keys.CopyTo(allAnimations, 0);
            List<SmoothMoves.BoneAnimation> animationList = new List<SmoothMoves.BoneAnimation>(allAnimations);

            //去除不必暫停物件
            if (dontStopAnimation != null)
                animationList.Remove(dontStopAnimation);

            for (int i = 0; i < animationList.Count; i++)
            {
                animationList[i].Stop();    //暫停BoneAnimation的運作
                this.AllBoneAnimationList[animationList[i]] = false;    //將狀態改為停止
            }
        }
    }
Ejemplo n.º 28
0
 /// <summary>
 /// 得到目前BoneAnimation的狀態(True為正在使用、False為暫停使用)
 /// </summary>
 /// <param name="boneAnimation">角色/敵人的BoneAnimation</param>
 /// <returns>目前BoneAnimation的狀態</returns>
 public bool GetBoneAnimationState(SmoothMoves.BoneAnimation boneAnimation)
 {
     return this.AllBoneAnimationList[boneAnimation];
 }
Ejemplo n.º 29
0
 bool Traverse(Action action, SmoothMoves.UserTriggerEvent triggerEvent)
 {
     if (action is ActionMotion)
     {
         ActionMotion actionMotion = action as ActionMotion;
         Dictionary<string, Routine> motionActions = new Dictionary<string, Routine>();
         foreach (var entity in actionMotion.taggedActions)
         {
             motionActions.Add(entity.Key,
                 delegate(SmoothMoves.UserTriggerEvent trigger)
                 {
                     Debug.Log(GetType() + " action fire!");
                     Debug.Log(DebugTool.GetFieldData(entity.Value));
                     Fire(entity.Value, trigger);
                 }
             );
         }
         PlayMotionWithAction(actionMotion.name, motionActions);
         return true;
     }
     else if (action is ActionVector)
     {
         ActionVector actionVector = action as ActionVector;
         var movement = VectorGenerator.Custom(actionVector.speedX, actionVector.speedY, actionVector.gravity, actionVector.toLeft);
         foreach (var target in FindTarget(actionVector.target))
         {
             if (target is FieldObject)
             {
                 (target as FieldObject).SetMove(movement);
             }
         }
         return true;
     }
     else if (action is ActionProjectile)
     {
         /*
         //Vector3 boneOffset = Vector3.zero;
         Vector3 boneOffset = new Vector3(0, 1);
         if (triggerEvent != null)
         {
             Transform parent = triggerEvent.boneTransform.parent;
             while (parent.name != "Root")
             {
                 parent = parent.parent;
             }
             boneOffset = triggerEvent.boneTransform.position - parent.position;
         }
         ActionProjectile actionProjectile = action as ActionProjectile;
         CreateProjectile(actionProjectile.projectileId, actionProjectile.action, boneOffset);
         */
         return true;
     }
     else if (action is ActionDelegate)
     {
         ActionDelegate actionDelegate = action as ActionDelegate;
         foreach (var entity in FindTarget(actionDelegate.target))
         {
             Automaton firer = entity as Automaton;
             if (firer != null)
             {
                 Action childAction = ActionPattern.Generate(actionDelegate.actionPattern, firer.Stat);
                 if (childAction != null)
                 {
                     firer.Fire(childAction, null);
                 }
             }
         }
         return true;
     }
     else if (action is ActionSingle)
     {
         ActionSingle actionSingle = action as ActionSingle;
         bool success = false;
         foreach (var target in FindTarget(actionSingle.Target))
         {
             if (target != null && target.IsActionApplicable(actionSingle.Type))
             {
                 success = true;
                 target.ApplyAction(actionSingle, this);
                 if (target is Subject2)
                 {
                     if (actionSingle.param != null)
                     {
                         foreach (var entity in actionSingle.param)
                         {
                             if (target is ObjectHolder)
                             {
                                 (target as ObjectHolder).AttachResource(entity, true);
                             }
                         }
                     }
                 }
             }
         }
         return success;
     }
     else if (action is ActionSequence)
     {
         bool lastSuccess = (action is ActionExclusive) ? false : true;
         foreach (var childAction in (action as ActionSequence).Actions)
         {
             if (action is ActionExclusive)
             {
                 if (lastSuccess)
                 {
                     break;
                 }
             }
             else if (!(action is ActionExclusive))
             {
                 if (!lastSuccess)
                 {
                     break;
                 }
             }
             lastSuccess = Traverse(childAction, triggerEvent);
         }
         return lastSuccess;
     }
     return false;
 }
Ejemplo n.º 30
0
 /// <summary>
 /// User Trigger delegate that is fired from the new weapon available animation
 /// </summary>
 /// <param name="utEvent">Event sent from the animation</param>
 public void NewWeaponAvailable_UserTrigger(SmoothMoves.UserTriggerEvent utEvent)
 {
     if (utEvent.tag == "Done")
     {
     #if UNITY_3_5
         newWeaponAvailableAnimation.gameObject.active = false;
     #else
         newWeaponAvailableAnimation.gameObject.SetActive(false);
     #endif
     }
 }