예제 #1
0
 //прерывание и смена состояния
 public virtual void changeStrategy(StrategysType strategyType)
 {
     if (_allStrategy.ContainsKey(strategyType)) {
         _currentStrategy = _allStrategy[strategyType];
         _currentStrategy.onStartState(_target);
         _target = _currentStrategy.target;
     }
 }
예제 #2
0
    public override void onAttack(AbstractInteractive target)
    {
        BasicCreature combatEnemy = (BasicCreature)target;
        if (Random.Range(0.0f, 1.0f) < stunChance) {

            StunStrategy stun = new StunStrategy (combatEnemy, stunTime);
            combatEnemy.creatureAI.changeStrategy(stun);
        }
    }
예제 #3
0
    public float[] fireEffect(EffectActionTypes[] keys, float[] paramList, AbstractInteractive target)
    {
        List<AbstracteEffect> effectList = getEffectListByKey(new HashSet<EffectActionTypes>(keys));

        foreach (AbstracteEffect effect in effectList) {
            paramList = effect.execute(keys, paramList, target);
        }
        return paramList;
    }
예제 #4
0
    void FixedUpdate()
    {
        if (_init && _currentStrategy.isFinish()) {
            _currentStrategy.onFinishState();
            setNewStrategy();

            _currentStrategy.onStartState(_target);
            _target = _currentStrategy.target;
        }
    }
예제 #5
0
 public override void onStartState(AbstractInteractive stateTarget)
 {
     _creature.fireEffect(
         new EffectActionTypes[] {EffectActionTypes.ON_DIE},
         new float[] {0},
         null
     );
     target = null;
     UnityEngine.Object.Destroy (_creature.creatureObject);
 }
예제 #6
0
    public void addState(AbstractStrategy strategy, bool mainState = false)
    {
        if (mainState == null)
            mainState = false;
        _allStrategy.Add (strategy.getStrategyType(), strategy);

        if (mainState) {
            _currentStrategy = strategy;
            _currentStrategy.onStartState(_target);
            _target = _currentStrategy.target;
        }
    }
예제 #7
0
        public override void OnInspectorGUI()
        {
            if (GUILayout.Button("Add Listener from scene"))
            {
                SelectListenerFromScene window = (SelectListenerFromScene)EditorWindow.GetWindow(typeof(SelectListenerFromScene), true, "Interactive listeners management");
                AbstractInteractive     monobehaviorPropertyEditor = (AbstractInteractive)target;
                window.SetInteractive(monobehaviorPropertyEditor);
                window.Show();
            }

            base.OnInspectorGUI();
        }
예제 #8
0
    public override void onStartState(AbstractInteractive strategyTarget)
    {
        target = strategyTarget;

        float[] returnedArr = _creature.fireEffect(
            new EffectActionTypes[] {EffectActionTypes.ON_START_CAPTURE, EffectActionTypes.GET_CAPTURE_TIME},
            new float[] {0, _creature.propertyConfig.captureTime.getCurrent()},
            target
        );
        float captureTime = returnedArr [1];

        // запустить this.__captureBuilding через _creature.captureTime сек.
        Timer.Instance.StartCoroutine(Timer.Instance.TimerStart(captureTime, __captureBuilding));
    }
예제 #9
0
 public override void onStartState(AbstractInteractive stateTarget)
 {
     //Найти ближайший маяк и передать его в target
     target = __findNextBeacon ();
     if(target != null) {
         _creature.agent.SetDestination(
             new Vector3(
             target.transform.position.x,
             target.collider.bounds.size.y + target.transform.position.y,
             target.transform.position.z
             )
         );
     }
 }
예제 #10
0
    public virtual float[] execute(EffectActionTypes[] keys, float[] paramsLis, AbstractInteractive target)
    {
        for (int i = 0; i < keys.Length; i++){
            switch (keys[i]){
                case EffectActionTypes.ON_START_CAPTURE :
                    onStartCapture(target);
                    break;

                case EffectActionTypes.ON_CAPTURE :
                    onCapture(target);
                    break;

                case EffectActionTypes.ON_DIE :
                    onDie();
                    break;

                case EffectActionTypes.ON_START_COMBAT :
                    onStartCombat(target);
                    break;

                case EffectActionTypes.ON_TAKE_DMG :
                    onTakeDmg(target);
                    break;

                case EffectActionTypes.ON_ATTACK :
                    onAttack(target);
                    break;

                case EffectActionTypes.GET_ARMOR :
                    paramsLis[i] = getArmor(paramsLis[i]);
                    break;

                case EffectActionTypes.GET_ATTACK_TIME :
                    paramsLis[i] = getAttackTime(paramsLis[i]);
                    break;

                case EffectActionTypes.GET_CAPTURE_TIME :
                    paramsLis[i] = getCaptureTime(paramsLis[i]);
                    break;

                case EffectActionTypes.GET_DMG :
                    paramsLis[i] = getDmg(paramsLis[i]);
                    break;

            }
        }
        return paramsLis;
    }
예제 #11
0
 //прерывание и смена состояния
 public virtual void changeStrategy(AbstractStrategy startegy)
 {
     _currentStrategy = startegy;
     _currentStrategy.onStartState(_target);
     _target = _currentStrategy.target;
 }
예제 #12
0
 public override void onStartState(AbstractInteractive stateTarget)
 {
     target = null;
     _creature.renderer.material.color = Color.blue;
     Timer.Instance.StartCoroutine(Timer.Instance.TimerStart(__stuneTime, __stunEnd));
 }
예제 #13
0
 /// <summary>
 /// After capture target
 /// </summary>
 /// <param name="target">Target.</param>
 public virtual void onCapture(AbstractInteractive target)
 {
 }
예제 #14
0
 public virtual void onAttack(AbstractInteractive target)
 {
 }
예제 #15
0
 /// <summary>
 /// Ons the start combat.
 /// </summary>
 /// <param name="target">Target - enemy in combat</param>
 public virtual void onStartCombat(AbstractInteractive target)
 {
 }
예제 #16
0
 public virtual void onStartState(AbstractInteractive stateTarget)
 {
 }
예제 #17
0
 public void SetInteractive(AbstractInteractive interactive)
 {
     this.interactive = interactive;
 }