Beispiel #1
0
 public override void Activate(int x, int y)
 {
     base.Activate(x, y);
     CharacterBhv.StartCoroutine(Helper.ExecuteAfterDelay(PlayerPrefsHelper.GetSpeed(), () =>
     {
         CharacterBhv.Instantiator.NewEffect(InventoryItemType.Skill, GridBhv.Cells[x, y].transform.position, null, EffectId, Constants.GridMax - CharacterBhv.Y);
         Debuff(GridBhv.IsOpponentOnCell(x, y));
         AfterActivation();
         return(true);
     }));
 }
Beispiel #2
0
 public override void Activate(int x, int y)
 {
     base.Activate(x, y);
     CharacterBhv.StartCoroutine(Helper.ExecuteAfterDelay(PlayerPrefsHelper.GetSpeed(), () =>
     {
         var result = Grap(GridBhv.IsOpponentOnCell(x, y));
         if (result == false)
         {
             AfterGrap();
         }
         return(true);
     }));
 }
Beispiel #3
0
 public override int OnTakeDamage(int damages)
 {
     if (IsApplyingEffect())
     {
         if (Helper.IsPosValid(_currentTargetX, _currentTargetX) && !GridBhv.IsOpponentOnCell(_currentTargetX, _currentTargetY, true, true))
         {
             CharacterBhv.MoveToPosition(_currentTargetX, _currentTargetY, false);
             CharacterBhv.Instantiator.NewEffect(InventoryItemType.Skill, GridBhv.Cells[_currentTargetX, _currentTargetY].transform.position, null, EffectId, Constants.GridMax - _currentTargetY);
         }
         EffectDuration = 0;
         CharacterBhv.LoseSkillEffect(Effect);
         return(0);
     }
     return(damages);
 }
Beispiel #4
0
 public override void BeginAction(Vector2 initialTouchPosition)
 {
     _isStretching        = true;
     transform.localScale = _pressedScale;
     _soundControler.PlaySound(_soundControler.ClickIn);
     if (Type == CellType.On || Type == CellType.OpponentSpawn)
     {
         var onCellCharacter = _gridBhv.IsOpponentOnCell(X, Y, true);
         if (onCellCharacter != null)
         {
             _fightSceneBhv.ShowCharacterLifeName(onCellCharacter.Character);
         }
         else
         {
             _fightSceneBhv.HideCharacterLifeName();
         }
     }
 }
Beispiel #5
0
 private bool Defend()
 {
     NewWeights(new List <int>());
     for (int i = 0; i < 2; ++i)
     {
         if (_characterBhv.Character.Skills[i].Nature == SkillNature.Defensive)
         {
             _weights.Add(_skillsWeight[i]);
         }
     }
     for (int i = 0; i < 2; ++i)
     {
         if (_characterBhv.Character.Skills[i].Nature == SkillNature.Defensive && IsTheBiggest(_skillsWeight[i]) && _skillsWeight[i] > 0)
         {
             int tmpX = _characterBhv.X;
             int tmpY = _characterBhv.Y;
             if (_characterBhv.Character.Skills[i].RangePositions != null && _characterBhv.Character.Skills[i].RangePositions.Count > 2) //2 Because List<int>
             {
                 List <int> tmpRangePos = new List <int>();
                 for (int j = 0; j < _characterBhv.Character.Skills[i].RangePositions.Count; j += 2)
                 {
                     var x = _characterBhv.Character.Skills[i].RangePositions[j] + tmpX;
                     var y = _characterBhv.Character.Skills[i].RangePositions[j + 1] + tmpY;
                     if (Helper.IsPosValid(x, y) &&
                         _gridBhv.Cells[x, y].GetComponent <CellBhv>().Type == CellType.On &&
                         !_gridBhv.IsOpponentOnCell(x, y, true, true))
                     {
                         tmpRangePos.Add(_characterBhv.Character.Skills[i].RangePositions[j]);
                         tmpRangePos.Add(_characterBhv.Character.Skills[i].RangePositions[j + 1]);
                     }
                 }
                 var rand = Random.Range(0, tmpRangePos.Count / 2);
                 tmpX += tmpRangePos[rand];
                 tmpY += tmpRangePos[rand + 1];
             }
             _characterBhv.Character.Skills[i].Activate(tmpX, tmpY);
             return(true);
         }
     }
     return(false);
 }
Beispiel #6
0
    public bool Push(CharacterBhv pushedOpponentBhv)
    {
        _pushedOpponentBhv = pushedOpponentBhv;
        if (_pushedOpponentBhv == null)
        {
            return(false);
        }
        int x = _pushedOpponentBhv.X - CharacterBhv.X;
        int y = _pushedOpponentBhv.Y - CharacterBhv.Y;

        if (!Helper.IsPosValid(_pushedOpponentBhv.X + x, _pushedOpponentBhv.Y + y) ||
            GridBhv.Cells[_pushedOpponentBhv.X + x, _pushedOpponentBhv.Y + y].GetComponent <CellBhv>().Type != CellType.On ||
            GridBhv.IsOpponentOnCell(_pushedOpponentBhv.X + x, _pushedOpponentBhv.Y + y, true))
        {
            if ((Helper.IsPosValid(_pushedOpponentBhv.X + x, _pushedOpponentBhv.Y + y) &&
                 GridBhv.Cells[_pushedOpponentBhv.X + x, _pushedOpponentBhv.Y + y].GetComponent <CellBhv>().Type == CellType.Off) ||
                GridBhv.IsOpponentOnCell(_pushedOpponentBhv.X + x, _pushedOpponentBhv.Y + y, true))
            {
                var floatAmount = 30.0f * CharacterBhv.Character.GetDamageMultiplier();
                //pushedOpponentBhv.TakeDamages(new Damage((int)floatAmount));
                var damage = new Damage((int)floatAmount);
                CharacterBhv.Instantiator.PopText("-" + pushedOpponentBhv.Character.TakeDamages(damage.Amount).ToString(), pushedOpponentBhv.transform.position, damage.Critical ? TextType.HpCritical : TextType.Hp);
                pushedOpponentBhv.SkinContainer.OnHit();
            }
            else if (!Helper.IsPosValid(_pushedOpponentBhv.X + x, _pushedOpponentBhv.Y + y) ||
                     GridBhv.Cells[_pushedOpponentBhv.X + x, _pushedOpponentBhv.Y + y].GetComponent <CellBhv>().Type == CellType.Impracticable)
            {
                pushedOpponentBhv.LosePm(1);
            }
            return(false);
        }
        _pushedOpponentBhv.AfterMouvementDelegate = AfterPush;
        _pushedOpponentBhv.MoveToPosition(_pushedOpponentBhv.X + x, _pushedOpponentBhv.Y + y, false);
        CharacterBhv.Instantiator.NewEffect(InventoryItemType.Skill, GridBhv.Cells[_pushedOpponentBhv.X + x, _pushedOpponentBhv.Y + y].transform.position, null, EffectId, Constants.GridMax - (_pushedOpponentBhv.Y + y));
        return(true);
    }