Пример #1
0
    private void FireInternal()
    {
        if (currentAmmo == 0)
        {
            return;
        }

        m_FireDelay = 0;
        //SetAmmo (-1);
        SoundManager.PlayMultiple(fireSound);

        FireCommand command       = m_FireCommands [0];
        Vector3     fireDirection = command.target.normalized;

        GameObject bullet = LevelGenerator.instance.SpawnObject(bulletPrefab);

        if (bullet.GetComponent <Bullet> ().IsFollowingShooter())
        {
            bullet.transform.SetParent(transform, false);
        }
        else
        {
            bullet.transform.position = transform.position;
        }
        bullet.transform.localScale *= command.sizeModifier;
        bullet.GetComponent <Rigidbody2D> ().velocity = ammoVelocity * fireDirection;
        bullet.GetComponentInChildren <SpriteRenderer> ().transform.rotation = new Quaternion(0, 0, Vector2.SignedAngle(Vector2.up, fireDirection), 0);

        command.Decrease();
        if (command.number == 0)
        {
            m_FireCommands.RemoveAt(0);
        }
    }
Пример #2
0
 private void TryFire()
 {
     bool shouldFire = ShouldFire();
     if (shouldFire) {
         FireCommand command = new FireCommand();
         command.Direction = m_fireDirection.CurrentDirection;
         command.FireControlString = m_fireControlString;
         SendMessage("FireWeapon", command, SendMessageOptions.DontRequireReceiver);
     }
 }
Пример #3
0
 public void Start()
 {
     fireCommand = gameObject.GetComponent<FireCommand> ();
     objectFire = fireCommand.objectFire.GetComponent<BubbleObj>();
     gameController = GameController.Instance ();
     actualBubble = GameObject.FindGameObjectWithTag ("ActualBubble").GetComponent<BubbleObj>();
     nextBubble = GameObject.FindGameObjectWithTag ("NextBubble").GetComponent<BubbleObj>();
     actualBubble.bubbleColor = Enums.getRandomBubbleColor ();
     nextBubble.bubbleColor = Enums.getRandomBubbleColor ();
 }
Пример #4
0
 private void FireWeapon(FireCommand command)
 {
     if (!m_launched && command.FireControlString == m_fireControlString) {
         SendMessage("StopMoving");
         rigidbody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ;
         rigidbody.AddForce(Vector3.down * 2f, ForceMode.Impulse);
         m_launched = true;
         this.enabled = true;
     }
 }
Пример #5
0
 private void FireWeapon(FireCommand command)
 {
     if (!m_launched && command.FireControlString == m_fireControlString)
     {
         SendMessage("StopMoving");
         rigidbody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ;
         rigidbody.AddForce(Vector3.down * 2f, ForceMode.Impulse);
         m_launched   = true;
         this.enabled = true;
     }
 }
Пример #6
0
 private void FireWeapon(FireCommand command)
 {
     if (!m_inCooldown && m_currentAmmo != 0 && command.FireControlString == m_fireControlString) {
         Vector3 pos = transform.position + m_shootingPointOffset;
         GameObject projectile = Instantiate(Projectile, pos, m_rotation) as GameObject;
         projectile.rigidbody.AddForce(command.Direction * ImpulseForce, ForceMode.Impulse);
         m_inCooldown = true;
         if (m_currentAmmo > 0) m_currentAmmo--;
         Invoke("ResetCooldown", Cooldown);
     }
 }
Пример #7
0
    private void TryFire()
    {
        bool shouldFire = ShouldFire();

        if (shouldFire)
        {
            FireCommand command = new FireCommand();
            command.Direction         = m_fireDirection.CurrentDirection;
            command.FireControlString = m_fireControlString;
            SendMessage("FireWeapon", command, SendMessageOptions.DontRequireReceiver);
        }
    }
Пример #8
0
 public Shooting(GameObject stateableParam)
 {
     stateable = stateableParam;
     fireCommand = stateable.GetComponent<FireCommand> ();
     VigilanteEnemy vigilante = stateable.GetComponent<VigilanteEnemy> ();
     Vector3 heading = stateable.transform.position - vigilante.enemyPos;
     float distance = heading.magnitude;
     Vector3 direction = heading / distance;
     vigilante.enemyPos = Vector3.zero;
     direction.x *= -10;
     direction.y *= -10;
     fireCommand.speed = direction;
 }
Пример #9
0
 // Update is called once per frame
 void Update()
 {
     foreach(string fireControlString in Enum.GetNames(typeof(FireControl))) {
         float fireAxisValue = Input.GetAxis(fireControlString);
         if (fireAxisValue != 0) {
             FireCommand command = new FireCommand();
             command.Direction = m_fireDirection.CurrentDirection;
             command.FireControlString = fireControlString;
             SendMessage("FireWeapon", command, SendMessageOptions.DontRequireReceiver);
             break; // break because you cannot fire 2 weapons at the same time
         }
     }
 }
Пример #10
0
    private void ProcessFireCommand()
    {
        FireCommand fireCommand   = m_FireCommands.Peek();
        Vector3     fireDirection = fireCommand.m_Target.normalized;

        if (Fire(fireDirection, fireCommand.m_SizeModifier))
        {
            fireCommand.DecreaseNumberOfShots();
            if (fireCommand.m_NumberOfShots == 0)
            {
                m_FireCommands.Dequeue();
            }
        }
    }
Пример #11
0
 private void FireWeapon(FireCommand command)
 {
     if (!m_inCooldown && m_currentAmmo != 0 && command.FireControlString == m_fireControlString)
     {
         Vector3    pos        = transform.position + m_shootingPointOffset;
         GameObject projectile = Instantiate(Projectile, pos, m_rotation) as GameObject;
         projectile.rigidbody.AddForce(command.Direction * ImpulseForce, ForceMode.Impulse);
         m_inCooldown = true;
         if (m_currentAmmo > 0)
         {
             m_currentAmmo--;
         }
         Invoke("ResetCooldown", Cooldown);
     }
 }
Пример #12
0
 // Update is called once per frame
 void Update()
 {
     foreach (string fireControlString in Enum.GetNames(typeof(FireControl)))
     {
         float fireAxisValue = Input.GetAxis(fireControlString);
         if (fireAxisValue != 0)
         {
             FireCommand command = new FireCommand();
             command.Direction         = m_fireDirection.CurrentDirection;
             command.FireControlString = fireControlString;
             SendMessage("FireWeapon", command, SendMessageOptions.DontRequireReceiver);
             break;                 // break because you cannot fire 2 weapons at the same time
         }
     }
 }
Пример #13
0
        public MainWindow()
        {
            InitializeComponent();

            var notify = Pulse.Lazy(() =>
            {
                Debug.WriteLine("Fire.");
                return(default(Unit));
            });

            FireCommand.Subscribe(async _ =>
            {
                var x = await notify;
                Debug.WriteLine(x);
            });

            DataContext = this;
        }
Пример #14
0
        //-----------------------------------------------------------------
        private void MainWindow_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == Key.Space)
            {
                MainWindow.JumpCommand jump = new JumpCommand();
                jump.Execute();
            }

            if (e.Key == Key.W)
            {
                ClimbCommand climb = new ClimbCommand();
                climb.Execute();
            }
            if (e.Key == Key.F)
            {
                FireCommand fire = new FireCommand();
                fire.Execute();
            }
        }
Пример #15
0
    public Command GetCommand()
    {
        /*어떤 키가 입력되었는지에 따라 각각의 Command변수들을 Retrurn.*/
        if (Input.GetAxis("Jump") != 0)
        {
            //점프키를 눌렀을시 점프명령을 보내줌.
            CmdJump = new JumpCommand();
            return(CmdJump);
        }

        if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)
        {
            //움직임이 있으면 Move명령을 보내주고 MoveCommand에 Horizontal, Vertical값을 넘겨줌
            CmdMove = new MoveCommand();
            MoveCommand.Vertical   = Input.GetAxis("Vertical");
            MoveCommand.Horizontal = Input.GetAxis("Horizontal");
            return(CmdMove);
        }

        if (Input.GetAxis("Fire1") != 0)
        {
            //발사는 마우스 위치에따라 나가게 처리.
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, 100))
            {
                //만약 클릭한 object의 테그가 Actor이면 Actor를 해당 게임오브젝트로 지정
                if (hit.transform.gameObject.tag == "Actor")
                {
                    RegistryCommandPattern.CURRENT_CUBE = hit.transform.gameObject;
                }
                else if (RegistryCommandPattern.CURRENT_CUBE != null)
                {
                    //클릭했는데 Actor가 null이 아니면 해당 Actor에게 발사명령을 보냄.
                    CmdFire = new FireCommand();
                    FireCommand.targetPosition = hit.point;
                    return(CmdFire);
                }
            }
        }
        return(null);
    }
Пример #16
0
    // Start is called before the first frame update
    new void Start()
    {
        base.Start();
        missilePool = new GameObject("MissilePool")
                      .AddComponent <ObjectPool>()
                      .setDynamic(false)
                      .setStartingSize(25)
                      .setPrefab(projectile);

        queue = ScriptableObject.CreateInstance <FireCommandQueue>();


        cooledDown = gameObject.AddComponent <CooledDown>()
                     .SetAction(() => {
            FireCommand command = queue.Dequeue();
            Shoot(command.direction);
            shouldCooldownInvoke();
        })
                     .SetCooldown(cooldown);
    }
Пример #17
0
        private static IGameWorld CreateWorld(IConsoleWriter consoleWriter)
        {
            var gameObjectLocator = new GameObjectLocator();

            var lineIntersectionResolver = new LianBarskyIntersectionResolver();
            var geometryMathService      = new GeometryMathService(lineIntersectionResolver);

            var serializedGameObjectDataProvider = new SerializedGameObjectDataProvider();
            var enemyData  = serializedGameObjectDataProvider.GetEnemyData();
            var playerData = serializedGameObjectDataProvider.GetPlayerData();
            var stoneData  = serializedGameObjectDataProvider.GetStoneData();
            var shellData  = serializedGameObjectDataProvider.GetShellData();

            var shellInputComponent   = new ShellInputComponent();
            var shellPhysicComponent  = new PhysicComponent(shellData.Speed);
            var shellLogicComponent   = new ShellLogicComponent();
            var shellGraphicComponent = new CharGraphicComponent(shellData.DisplayChar, consoleWriter);
            var shell = new GameObject(shellInputComponent, shellPhysicComponent,
                                       shellLogicComponent, shellGraphicComponent);

            shell.Width  = shellData.Width;
            shell.Height = shellData.Height;
            var fireCommand = new FireCommand(shell);

            var serializedGameObjectBuilders = new List <ISerializedGameObjectBuilder>()
            {
                new StoneBuilder(consoleWriter, stoneData),
                new PlayerBuilder(consoleWriter, geometryMathService, fireCommand, playerData),
                new EnemyBuilder(consoleWriter, gameObjectLocator, geometryMathService, fireCommand, enemyData),
                new WinPlatformBuilder(consoleWriter, gameObjectLocator, geometryMathService)
            };

            var gameObjectBuilder = new GameObjectBuilder(serializedGameObjectBuilders, gameObjectLocator);

            var worldProvider = new WorldProvider(gameObjectBuilder, geometryMathService, consoleWriter);
            var world         = worldProvider.GetWorld(1);

            return(world);
        }
Пример #18
0
 public void ApplyCommand(FireCommand command) => this.ApplyDefault(command);
Пример #19
0
        static void Main()
        {
            //1
            WarriorFactory warriorFactory = new SwordFactory();
            List <IElf>    elves          = warriorFactory.CreateElf(4);

            //2
            elves.Add(WarELfLord.getInstance());
            Printer.PrintWarrior(elves);

            //3
            Builder  builder  = new ConcreteBuilder();
            Director director = new Director(builder);

            director.Construct();
            Castle castle = builder.GetResult();

            Console.WriteLine(castle.ToString());

            //4
            Archer archer      = new OgreArcher(7);
            Archer archerClone = archer.Clone();

            Console.WriteLine(archer.Damage + " " + archerClone.Damage);

            archer      = new ElfArcher(9);
            archerClone = archer.Clone();
            Console.WriteLine(archer.Damage + " " + archerClone.Damage);

            //1
            SwordElf         swordElf         = new SwordElf();
            ImprovedSwordElf improvedSwordElf = new Adapter(swordElf);

            improvedSwordElf.Function();
            Console.WriteLine(swordElf.HitPoints + " " + improvedSwordElf.HitPoints);
            //2
            BuildMaterial buildMaterial = new Wood();

            buildMaterial = new WithTiles(buildMaterial);
            Console.WriteLine(buildMaterial.Name + " price: " + buildMaterial.GetCost());

            buildMaterial = new Stone();
            Console.WriteLine(buildMaterial.Name + " price: " + buildMaterial.GetCost());
            buildMaterial = new WithCreepers(buildMaterial);
            Console.WriteLine(buildMaterial.Name + " price: " + buildMaterial.GetCost());

            //3
            Map     map           = new Map("Europe");
            Country country       = new Country("Germany");
            Map     subMap        = new Map("Baltic");
            Country balticCountry = new Country("Lithuania");

            subMap.AddComponent(balticCountry);
            map.AddComponent(country);
            map.AddComponent(subMap);
            Console.WriteLine();
            var item = map.Find("Lithuania");

            if (item != null)
            {
                item.Draw();
            }
            else
            {
                Console.WriteLine("null");
            }
            Console.WriteLine();
            item = map.Find("Lidgdfg");
            if (item != null)
            {
                item.Draw();
            }
            else
            {
                Console.WriteLine("null");
            }
            Console.WriteLine();
            map.Draw();

            //1
            Invoker     invoker     = new Invoker();
            Receiver    receiver    = new Receiver();
            JumpCommand jumpCommand = new JumpCommand(receiver);

            invoker.SetCommand(jumpCommand);
            invoker.Run();
            FireCommand fireCommand = new FireCommand(receiver);

            invoker.SetCommand(fireCommand);
            invoker.Run();
            //2

            var input = new Input(Console.ReadKey());
            var hero  = new MyObject(new Jumping());

            hero.HandleRequest(input);
            hero.GetObjectStatus();

            //3
            var improvedSwordOgre = new ImprovedSwordOgre();
            var history           = new GameHistory();

            improvedSwordOgre.Injure();
            Console.WriteLine(improvedSwordOgre.HitPoints + " " + improvedSwordOgre.Damage);
            var improvedSwordOgreMemento =
                new ImprovedSwordOgreMemento(improvedSwordOgre.HitPoints, improvedSwordOgre.Damage);

            history.History.Push(improvedSwordOgreMemento);
            improvedSwordOgre.Injure();
            Console.WriteLine(improvedSwordOgre.HitPoints + " " + improvedSwordOgre.Damage);
            //restoring
            improvedSwordOgre.HitPoints = improvedSwordOgreMemento.HitPoints;
            improvedSwordOgre.Damage    = improvedSwordOgreMemento.Damage;
            Console.WriteLine(improvedSwordOgre.HitPoints + " " + improvedSwordOgre.Damage);

            //4
            Attack   attack    = new Attack();
            Defender defender1 = new Defender(22, attack);
            Defender defender2 = new Defender(27, attack);

            attack.AddObserver(defender1);
            attack.AddObserver(defender2);
            attack.UpdateStatus();

            //WarriorFactory guardFactory = new GuardsFactory();
            //List<IOgre> ogres = guardFactory.CreateOgre(2);
            var ogre = new GuardOgre();

            ogre.Execute();
            ogre.Damaged(30);
            ogre.Execute();
            ogre.Damaged(50);
            ogre.Execute();
            //ogres.FirstOrDefault().strategy =

            //foreach(IOgre ogre in ogres)
            //{
            //    ogre.strategy.
            //}

            Console.ReadKey();
        }
Пример #20
0
    private IEnumerator MultiGunFireHandler()
    {
        while (true)
        {
            yield return(null);

            if (!isRunning)
            {
                continue;
            }

            if (fireToExecute.Count > 0)
            {
                FireCommand command = fireToExecute.Dequeue();
                switch (command)
                {
                case FireCommand.FireOneReady:
                    for (int i = 0; i < guns.Length; i++)
                    {
                        if (guns[i].IsReady)
                        {
                            guns[i].holdFire = false;
                            yield return(null);

                            guns[i].holdFire = true;
                            break;
                        }
                    }
                    bulletsFired++;
                    break;

                case FireCommand.FireAll:
                    for (int i = 0; i < guns.Length; i++)
                    {
                        if (guns[i].IsReady)
                        {
                            guns[i].holdFire = false;
                        }
                    }
                    bulletsFired += guns.Length;
                    yield return(null);

                    for (int i = 0; i < guns.Length; i++)
                    {
                        guns[i].holdFire = true;
                    }
                    break;

                case FireCommand.WaitAllRotationsReady:
                    for (int i = 0; i < rotatingParts.Length; i++)
                    {
                        while (!rotatingParts[i].IsIdle)
                        {
                            yield return(null);
                        }
                    }
                    break;

                case FireCommand.WaitOneRotationReady:
                    bool oneRotationDone = false;
                    while (!oneRotationDone)
                    {
                        for (int i = 0; i < rotatingParts.Length; i++)
                        {
                            if (rotatingParts[i].IsIdle)
                            {
                                oneRotationDone = true;
                                break;
                            }
                        }
                    }
                    break;

                default:
                    Debug.Log("Skipped fire command: " + command);
                    break;
                }
            }
            pastEvents.Enqueue(ReportedEvent.FireCommandComplete);
        }
    }
Пример #21
0
 public void Fire(FireCommand type)
 {
     fireToExecute.Enqueue(type);
 }
Пример #22
0
 public Shooting(GameObject stateableParam)
 {
     stateable = stateableParam;
     fireCommand = stateable.GetComponent<FireCommand> ();
 }
Пример #23
0
        /// <summary>
        /// The Fire Command
        ///
        /// @return the Task<CommandResult> command result Task
        /// </summary>
        public Task <CommandResult> FireCommand()
        {
            FireCommand command = new FireCommand();

            return(Send(command));
        }