Ejemplo n.º 1
0
        public void OnEvent(List <Tuple <string, Vector3> > hit)
        {
            var updateHPCommand = new ParallelCommand();

            foreach (var data in hit)
            {
                IUnit unit = _unitsFactory.CreateUnit <IUnit>(data.Item1);
                unit.HP       = 100;
                unit.Attack   = 23;
                unit.Position = data.Item2;
                _gameScene.Units.Add(unit);
                updateHPCommand.Commands.Add(new UpdateUnitHP(unit));
            }

            _commandsManager.ExecuteCommand(updateHPCommand);
        }
Ejemplo n.º 2
0
        public void OnEvent(IUnit source, IUnit target)
        {
            if (target.HP <= 0)
            {
                return;
            }

            IUnit rocket = _unitsFactory.CreateUnit <IUnit>("rocket_0");

            rocket.Position = new Vector3(source.Position.x, 1.0f, source.Position.z);
            Vector3 targetPosition = new Vector3(target.Position.x, 1.0f, target.Position.z);

            target.HP -= source.Attack;

            var moveRocketCmd = new SequenceCommand(
                new MoveByPath(rocket, new Vector3[] { rocket.Position, targetPosition }, 3f),
                new PunchUnit(rocket, Vector3.one, 1f),
                new UpdateUnitHP(target),
                new ActionCommand(() =>
            {
                GameObject.Destroy(rocket.Owner);
            })
                );

            if (target.HP <= 0)
            {
                moveRocketCmd.Commands.Add(new PunchUnit(target, Vector3.one, 1f));
                moveRocketCmd.Commands.Add(new ActionCommand(() =>
                {
                    _gameScene.Units.Remove(target);
                    GameObject.Destroy(target.Owner);
                }));
            }

            _commandsManager.ExecuteCommand(moveRocketCmd);
        }