Пример #1
0
 protected override void Start()
 {
     actionComponent = GetComponent <ActionComponent>();
     unitInfo        = GetComponent <UnitInfo>();
     movement        = GetComponent <CharacterMovement>();
     ik = unitInfo.GetComponent <GenericIK>();
     unitInfo.AddDamageEvent(delegate(UnitInfo _causer, float _damage)
     {
         if (unitInfo.GetHP() <= 0)
         {
             SetState(AIState.die);
             return;
         }
         float[] roarHPs = { 75, 50, 25 };
         for (int i = 0; i < roarHPs.Length; i++)
         {
             if (unitInfo.GetLastHP() > roarHPs[i] && unitInfo.GetHP() <= roarHPs[i])
             {
                 if (unitInfo.GetCondition() >= ConditionData.UnitCondition.stuned)
                 {
                     unitInfo.GetComponent <ActionComponent>().UseSkill("WakeUp", true);
                 }
                 readyType = ActionReadyType.Roar;
                 unitInfo.RemoveCrowdControlAll();
             }
         }
     }
                             );
     unitInfo.AddStateChangeEvent(delegate(UnitInfo.UnitState _new, UnitInfo.UnitState _old)
     {
     }
                                  );
     weaknessPointObject.AddEvent(
         delegate(Transform caller)
     {
         Debug.Log(caller);
         StartCoroutine(DisappearWeakness());
         unitInfo.AddCrowdControl(ConditionData.UnitCondition.stuned, 5,
                                  delegate()
         {
             unitInfo.GetComponent <ActionComponent>().UseSkill("WakeUp", true);
             StartCoroutine(AppearWeakness(UnityEngine.Random.Range(0, weaknessPoints.Count)));
         }
                                  );
         actionComponent.StopAction();
         movement.Stop();
         movement.StopRotating();
     }
         );
     actionTarget = new GameObject(transform.name + " Action Target").transform;
     StartCoroutine(AppearWeakness(UnityEngine.Random.Range(0, weaknessPoints.Count)));
     base.Start();
     //actionTarget = pivot;
 }
Пример #2
0
    public override IEnumerator BuffCoroutine(UnitInfo owner)
    {
        AddBuffAction(owner);
        Rigidbody rigidbody     = owner.GetComponent <Rigidbody>();
        float     buffTimeCount = buffTime;

        do
        {
            if (!owner.GetMovement().isOnGround)
            {
                Vector3 newVelocity = rigidbody.velocity;
                if (newVelocity.y < 0)
                {
                    /*newVelocity.y *= 0.8f;
                     * rigidbody.velocity = newVelocity;*/
                }
            }
            buffTimeCount -= Time.deltaTime;
            yield return(null);
        } while (buffTimeCount > 0);
        ActionBehaviour aBehaviour = owner.GetAction().GetBehaviour("Flying");

        if (aBehaviour)
        {
            owner.GetAction().RemoveAction(aBehaviour);
            GameObject.Destroy(aBehaviour.gameObject);
        }
        owner.RemoveBuff(this);
    }
Пример #3
0
        public void Load(LevelObject levelObject)
        {
            this.levelObject = levelObject;

            LevelIcon.sprite     = levelObject.Ico;
            MapName.text         = levelObject.LevelInfo.LevelName;
            RecomendedLevel.text = levelObject.LevelInfo.RecomendedLevel;
            Description.text     = levelObject.LevelInfo.LevelDiscription;

            List <unitCategory> unitsCategory = new List <unitCategory>();

            foreach (UnitObject unit in levelObject.Units)
            {
                bool haveCategory = false;

                foreach (unitCategory ct in unitsCategory)
                {
                    if (unit == ct.unitImage)
                    {
                        haveCategory = true;
                        ct.number++;
                    }
                }
                if (!haveCategory)
                {
                    unitsCategory.Add(new unitCategory(unit));
                }
            }

            if (UnitParent.childCount > 0)
            {
                for (int i = 0; i < UnitParent.childCount; i++)
                {
                    Destroy(UnitParent.GetChild(i).gameObject);
                }
            }
            foreach (unitCategory uc in unitsCategory)
            {
                UnitInfo unitInfo = Instantiate <UnitInfo>(UnitPrefab, UnitParent);
                unitInfo.Load(uc.unitImage, uc.number);
                unitInfo.GetComponent <Button>().onClick.AddListener(() => LoadUnitInfo(uc.unitImage));
                unitInfo.GetComponent <Button>().onClick.AddListener(() => OnClickAction.Invoke());
            }
        }
Пример #4
0
    protected override IEnumerator EventCoroutine()
    {
        CharacterMovement.MOVING_TYPE lastMovingType = CharacterMovement.MOVING_TYPE.ground;
        List <int> pillarOrder = new List <int>();

        for (int i = 0; i < pillars.Length; i++)
        {
            pillarOrder.Add(i);
        }
        for (int i = 0; i < pillars.Length * 2; i++)
        {
            int j  = UnityEngine.Random.Range(0, pillars.Length);
            int jj = UnityEngine.Random.Range(0, pillars.Length);
            int a  = pillarOrder[j];
            int b  = pillarOrder[jj];
            Swap(ref a, ref b);
            pillarOrder[j]  = a;
            pillarOrder[jj] = b;
        }
        AIBase ai = boss.GetComponent <AIDragon>();

        ai.SetTargetUnit(eventPlayer);
        while (true)
        {
            if (boss.GetMovement().GetMovingType() != lastMovingType)// On changed moving Type
            {
                lastMovingType = boss.GetMovement().GetMovingType();
                if (lastMovingType == CharacterMovement.MOVING_TYPE.flying)
                {
                    int p = pillarOrder[0];
                    Debug.Log(p);
                    pillarOrder.RemoveAt(0);
                    Material mat = pillars[p].GetComponent <MeshRenderer>().material;
                    mat.color = Color.red;
                    pillars[p].SetEnable(true);
                    pillars[p].AddEvent(
                        delegate(Transform caller)
                    {
                        if (caller.tag == "Player")
                        {
                            boss.GetMovement().SetMovingType(CharacterMovement.MOVING_TYPE.ground);
                            pillars[p].SetEnable(false);
                            mat.color = Color.black;
                        }
                    }
                        );
                }
                else
                {
                }
            }
            yield return(null);
        }
        yield return(null);
    }