Beispiel #1
0
    private bool UpdateCharacterClick()
    {
        if (Input.GetMouseButtonDown(0))
        {
            var screenRay        = Camera.main.ScreenPointToRay(Input.mousePosition);
            var clickedCharacter = EMCharacter.Instances.FirstOrDefault(_ => _.IntersectRay(screenRay));

            if (clickedCharacter != null)
            {
                if (_currentCharacter != null)
                {
                    _currentCharacter.NotifySelectionChange(false);
                }

                clickedCharacter.NotifySelectionChange(true);
                _currentCharacter = clickedCharacter;

                EventSystem.RaiseEvent(new Clicked {
                    ClickTarget = clickedCharacter
                });

                return(true);
            }
        }

        return(false);
    }
Beispiel #2
0
        public void SetCharacterAtCell(int x, int y, EMCharacter character)
        {
            var cell = GetCell(x, y);

            if (cell != null)
            {
                cell.Character = character;
            }
        }
Beispiel #3
0
            public bool CanAttack(EMCharacter target)
            {
                if (target == null)
                {
                    return(false);
                }

                var thisCharacter  = Character as EMCharacter;
                var otherCharacter = target;

                return(Mathf.Abs(thisCharacter.X - otherCharacter.X) <= typedInfo.AttackRange);
            }
Beispiel #4
0
            public void Attack(EMCharacter target)
            {
                var thisCharacter  = Character as EMCharacter;
                var otherCharacter = target;
                var direction      = new Vector3(otherCharacter.X - thisCharacter.X, otherCharacter.Y - thisCharacter.Y);

                if (typedInfo._attackEffectPrefab != null)
                {
                    var attackEffectInstance = Instantiate(typedInfo._attackEffectPrefab);
                    attackEffectInstance.Launch(thisCharacter, direction.ToXZ(), 5f, 0, false, 0f);
                }

                target.Damage(typedInfo.BaseDamage);
            }
    public EMCharacter Spawn()
    {
        var result = _characterInfo.GetCharacter(_battleGrid);

        if (_startFromEnd)
        {
            result.SetPosition(_battleGrid.GetWidth() - 1, 0, updatePawnPosition: true);
        }

        result.MoveBy(_startOffsetX, _startOffsetY);

        _spawnedCharacter = result;
        var weapon = _startingWeaponInfo.GetItem();

        weapon.SetCharacter(_spawnedCharacter);
        weapon.Apply();
        //_spawnedCharacter.Inventory.SetArmSlotItem( ArmSlotType.Primary, _startingWeaponInfo.GetItem() );

        return(result);
    }
Beispiel #6
0
 public virtual void Initialize(EMCharacter character)
 {
     Character = character;
 }
Beispiel #7
0
 public Attack(EMCharacter owner, int moveDirection)
 {
     _owner         = owner;
     _moveDirection = moveDirection;
 }
Beispiel #8
0
        public override void Initialize(EMCharacter character)
        {
            base.Initialize(character);

            EventSystem.Events.SubscribeOfType <EMClickInput.Clicked>(OnObjectClick);
        }
Beispiel #9
0
 public Move(EMCharacter owner, int direction)
 {
     _owner     = owner;
     _direction = direction;
 }