예제 #1
0
 // Use this for initialization
 void Awake()
 {
     manimator    = GetComponent <Animator>();
     playerMove   = GetComponent <PlayerMove>();
     render       = GameObject.FindWithTag(Tags.PlayerRender).GetComponent <SkinnedMeshRenderer>();
     shootManager = this.GetComponentInChildren <ShootManager>();
 }
예제 #2
0
    Shot currentShot;                 // the current shot we are playing to acces it's attributes

    private void Start()
    {
        animator = GetComponent <Animator>();          // referennce out animator
        aimTargetInitialPosition = aimTarget.position; // initialise the aim position to the center( where we placed it in the editor )
        shotManager = GetComponent <ShootManager>();   // accesing our shot manager component
        currentShot = shotManager.topSpin;             // defaulting our current shot as topspin
    }
예제 #3
0
 // Use this for initialization
 void Start()
 {
     onStart      = false;
     shootScript  = GetComponent <Shoot>();
     pm           = GetComponent <PlayerManager>();
     sm           = GetComponent <ShootManager>();
     comboManager = GetComponent <Combo>();
     //spawner = GetComponent<SpawnEnemiesInWaves>();
 }
예제 #4
0
 void Start()
 {
     sector = Object.Instantiate(Resources.Load <GameObject> ("levelPublic/ShootSector")) as GameObject;
     sector.SetActive(false);
     GameObject.DontDestroyOnLoad(sector);
     sm      = GetComponent <ShootManager> ();
     attr    = NetworkUtil.GetAttr(this.gameObject);
     sm.attr = attr;
 }
예제 #5
0
    public void Shoot(float inputDistance, float inputAngle)
    {
        ShootManager.Shoot(inputDistance, inputAngle, m_perfectShootNormalizedValue, m_ball);

        if (Mathf.Abs(inputDistance - m_perfectShootNormalizedValue) < StaticConf.Gameplay.PERFECT_SHOOT_POWER_TOLLERANCE_NORMALIZED)
        {
            m_perfectShootBonus = StaticConf.Score.PERFECT_SHOOT_BONUS;
        }

        m_ballShooted = true;
    }
예제 #6
0
 private void Start()
 {
     _movementAnimator = GetComponent <Animator>();
     _galaxy           = GameObject.Find("Galaxy").transform;
     _uiManager        = GameObject.FindGameObjectWithTag("UI Manager").GetComponent <UIManager>();
     _uiManager.UpdateLives(_life);
     _shootManager = GetComponent <ShootManager>();
     _xLimit       = _galaxy.localScale.x / 2.0f;
     _yLimit       = _galaxy.localScale.y / 2.0f;
     _mainMenu     = Resources.FindObjectsOfTypeAll <MainMenu>()[0];
 }
예제 #7
0
        public void NotSunken()
        {
            var shootManager = new ShootManager();

            int         shipIndex = 0;
            List <Ship> ships     = InitializeShips();

            bool result = shootManager.IsSunken(ships[0]);

            result.Should().BeFalse();
        }
예제 #8
0
    void Awake()
    {
        shootManager = gameObject.AddComponent <ShootManager>();
        selfStats    = GetComponentInParent <CharacterStats>();
        inventory    = GetComponentInParent <Inventory>();
        equipment    = GetComponentInParent <Equipment>();
        meleePoint   = GetComponentInChildren <MeleePoint>();
        shootManager.setParameters(characterGFX, firePoint, equipment);

        equipment.onWeaponChanged += UpdateWeapon;
        UpdateWeapon(equipment.weapon);
    }
예제 #9
0
        public void HurtAircraft()
        {
            IShootManager shootManager = new ShootManager();

            var ships = InitializeShips();

            var hitShipPosition = new Position(0, 0);

            Ship theShip = shootManager.HittedShip(hitShipPosition, ships);
            var  result  = theShip.ShipType;

            result.Should().Be(ShipType.AircraftCarrier);
        }
예제 #10
0
        public void InWater()
        {
            IShootManager shootManager = new ShootManager();

            var ships = InitializeShips();

            var hitShipPosition = new Position(9, 9);

            var result = shootManager.HittedShip(hitShipPosition, ships);


            result.Should().Be(null);
        }
예제 #11
0
        public void HurtCruiser()
        {
            IShootManager shootManager = new ShootManager();

            var ships = InitializeShips();

            var hitShipPosition = new Position(2, 1);

            var theShip = shootManager.HittedShip(hitShipPosition, ships);
            var result  = theShip.ShipType;

            result.Should().Be(ShipType.Cruiser);
        }
예제 #12
0
파일: ShootManager.cs 프로젝트: inhart/Demo
    private void Awake()
    {
        if (shm == null)
        {
            shm = this;
        }
        else if (shm != this)
        {
            Destroy(gameObject);
        }
        player = GameObject.Find("Player").transform;

        shotImage = FindObjectOfType <CurrentShotImage>();
    }
    public void UpdateButtonPressed()
    {
        for (int i = 0; i < Destruction.Length; i++)
        {
            DestroyAllChildren(Destruction[i]);
        }

        for (int i = 0; i < ToInactivate.Length; i++)
        {
            ToInactivate[i].SetActive(false);
        }

        ShootManager.EmptyDictionaries();
    }
예제 #14
0
        public void OnePositionHit()
        {
            var shootManager = new ShootManager();

            int         shipIndex = 0;
            List <Ship> ships     = InitializeShips();

            //be hited once
            Position iShootPosition = new Position(0, 1);

            shootManager.RemoveHitPosition(iShootPosition, ships);

            bool result = shootManager.IsSunken(ships[0]);

            result.Should().BeFalse();
        }
예제 #15
0
        public void SubmarineSunken()
        {
            var shootManager = new ShootManager();

            int         shipIndex = 4;
            List <Ship> ships     = InitializeShips();

            //be hited twice
            Position iShootPosition1 = new Position(8, 8);

            shootManager.RemoveHitPosition(iShootPosition1, ships);

            bool result = shootManager.IsSunken(ships[4]);

            result.Should().BeTrue();
        }
예제 #16
0
 void Awake()
 {
     if (null == instance)
     {
         instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
     else
     {
         Destroy(this.gameObject);
     }
     Power = Min_Power;
     Score = 0;
     EndPanel.SetActive(false);
     Score_obj.SetActive(true);
     Power_slider_obj.SetActive(true);
 }
    void Shoot()
    {
        //Vector3 rayOrigin = cam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0.0f));

        RaycastHit _hit;

        Ray ray = cam.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out _hit, range, mask))
        {
            if (_hit.collider.tag == _shootableMesh)
            {
                _hit.transform.GetComponent <EmissionController>().ToggleEmission();
                ShootManager.ShootConnections(_hit.collider.name);
            }
        }
    }
예제 #18
0
 private void ConditionalExpandShooting()
 {
     // the double conditional KeyDown and KeyUp seems a bit silly
     // but it ensures that the selection doesn't keep spreading
     // with only the first condition the next selected objects will also sometimes fire and select the next etc
     // presumably if their update is called slightly later in the framee they will already have emission== true and the key press is still active
     // this way only objects that had emission on when the key is pressed will pass their id to KeepShooting once the key is released (and since the emissions are only set after the key releease, the next elements cannot have emission == true and keyDown)
     if (emission == true & Input.GetKeyDown(KeyCode.N))
     {
         fire = true;
     }
     if (fire == true & Input.GetKeyUp(KeyCode.N))
     {
         ShootManager.ShootInDirectConnections(transform.name);
         fire = false;
     }
 }
예제 #19
0
        public void ComputerCruiserHasSunken()
        {
            List <Ship> playerShips   = InitializePlayerShips();
            List <Ship> computerShips = InitializePcShips();

            // PC Cruiser Sunken
            ShootManager shootManager = new ShootManager();

            shootManager.RemoveHitPosition(new Position(2, 0), computerShips);
            shootManager.RemoveHitPosition(new Position(2, 1), computerShips);
            shootManager.RemoveHitPosition(new Position(2, 2), computerShips);

            string result = GraphicManager.DisplayBattleTables(playerShips, computerShips);

            bool isExist3 = result.Contains("Cruiser");

            isExist3.Should().BeTrue();
        }
예제 #20
0
        public void ThreePositionsHit()
        {
            var shootManager = new ShootManager();

            int         shipIndex = 0;
            List <Ship> ships     = InitializeShips();

            //be hited twice
            Position iShootPosition1 = new Position(0, 1);
            Position iShootPosition2 = new Position(0, 2);
            Position iShootPosition3 = new Position(0, 3);

            shootManager.RemoveHitPosition(iShootPosition1, ships);
            shootManager.RemoveHitPosition(iShootPosition2, ships);
            shootManager.RemoveHitPosition(iShootPosition3, ships);

            bool result = shootManager.IsSunken(ships[0]);

            result.Should().BeFalse();
        }
예제 #21
0
 void Update()
 {
     if (Input.GetKey(KeyCode.C))
     {
         dist = player.transform.position - transform.position;
         if (dist.magnitude <= 1)
         {
             int random = Random.Range(0, Bullets.Length);
             if (showDrop == 0)
             {
                 GameObject go = Instantiate(Bullets[random]);
                 go.transform.position = transform.position;
                 //Debug.Log("Chest OnTriggerEnter_Press C_ Random: " + random);
                 anim.SetTrigger("Input");
                 sm = player.transform.GetComponent <ShootManager>();
                 sm.SetBullet(random);
                 showDrop++;
             }
         }
     }
 }
예제 #22
0
 private void Start()
 {
     UIGroup.SetActive(false);
     ShootM = this.GetComponent <ShootManager>();
 }
예제 #23
0
 public void Setup(ShootManager gun, int index)
 {
     this.gun   = gun;
     this.index = index;
 }
예제 #24
0
파일: Bot.cs 프로젝트: yaelandau22/Tennis
 void Start()
 {
     targetposition = transform.position;
     animator       = GetComponent <Animator>();
     shotmanager    = GetComponent <ShootManager>();
 }
예제 #25
0
 // Use this for initialization
 void Start()
 {
     sm = GetComponent <ShootManager>();
 }
예제 #26
0
 void Start()
 {
     shootManager = new ShootManager(5);
     PrepareGame();
 }
예제 #27
0
    /*
     * [SerializeField]
     * GameObject iAmPrivate; i will appear in the inspector but im public
     */

    private void Start()
    {
        Instance = this;

        allShots = new List <GameObject>();
    }
예제 #28
0
        public static void Main()
        {
            #region [on] 0. Instance
            var battlefield = new Battlefield(10, 10);
            positionParser    = new PositionParser();
            positionValidator = new PositionValidator();
            randomManager     = new RandomManager();
            shipManager       = new ShipManager();
            shootManager      = new ShootManager();
            placeManager      = new PlaceManager();
            var battleBgm = new WindowsMediaPlayer();
            var winnerBgm = new WindowsMediaPlayer();

            #endregion


            #region [off] 1. Welcome Screen
            //GraphicManager.WelcomeScreen();
            #endregion


            #region [on] 1.1. BGM

            SoundEffects.BattleBgmPlayer(battleBgm);

            #endregion


            #region [on] 2. Ships Topf

            // instance two players
            var player = new Player();
            player.Positions = new List <Position>();
            player.Hits      = new List <Hit>();
            player.Ships     = new List <Ship>();

            var computer = new Player();
            computer.Positions = new List <Position>();
            computer.Hits      = new List <Hit>();
            computer.Ships     = new List <Ship>();

            #endregion


            #region [on] 3. Place PlayerShips and ComputerShips

            // create player Ships
            player.Ships = InitializeShips();
            // place player ships
            // [!!]  placeManager.PlacePlayerShips(player.Ships, positionParser, positionValidator, shipManager,battlefield);
            placeManager.PlaceComputerShips(player.Ships, randomManager, shipManager, positionValidator, battlefield);

            // create ships for pc
            computer.Ships = InitializeShips();
            // place pc ships
            placeManager.PlaceComputerShips(computer.Ships, randomManager, shipManager, positionValidator, battlefield);

            // Add positions into Instances
            foreach (var playerShip in player.Ships)
            {
                player.Positions.AddRange(playerShip.Positions);
            }
            var allPlayerShipsPositions = player.Positions;

            foreach (var computerShip in computer.Ships)
            {
                computer.Positions.AddRange(computerShip.Positions);
            }
            var allComputerShipsPositions = computer.Positions;

            #endregion


            #region + [on] display pcShips for Testing
            Console.Clear();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("        God Mode");
            Console.WriteLine("        PC Ships:");
            Console.WriteLine();
            Console.WriteLine(GraphicManager.DisplayBattlefield(battlefield.ColumnSize, battlefield.RowSize, computer.Ships).PadRight(20));
            Console.ReadKey();
            SoundEffects.SetShipSoundPlayer();
            #endregion


            #region  + [off] display Win view for Testing

            //battleBgm.close();
            //EndGameManager.WhoWin(player, computer, winnerBgm, shootManager);
            //EndGameManager.RestartGame(winnerBgm);

            #endregion


            #region [on] 4. Game begin view

            GraphicManager.GameStartView(player, computer, battlefield);

            #endregion


            #region [on] 5. Player || PC shots
            do     // End the Game
            {
                do // Player == * ==> PC
                {
                    var iShootPosition = ShootManager.PlayerShoot(player, computer, battlefield, positionParser, positionValidator);

                    if (allComputerShipsPositions.Contains(iShootPosition)) // Hit Ship
                    {
                        computer.Hits.Add(new Hit(HitType.Ship, iShootPosition));
                        shootManager.HitShip(player, computer, iShootPosition, computer.Ships, battlefield);
                    }
                    else // Hit Water
                    {
                        computer.Hits.Add(new Hit(HitType.Water, iShootPosition));
                        shootManager.HitWater(player, computer, iShootPosition, battlefield, positionParser);
                    }

                    // Is all Player Ships Sunken
                    if (shootManager.IsAllShipsSunken(computer.Ships))
                    {
                        break;
                    }
                } while (computer.Hits.Last().HitType == HitType.Ship); // one more time shoot


                do // PC == * ==> Player
                {
                    // if All player ships have Sunked skip all those code
                    if (shootManager.IsAllShipsSunken(computer.Ships))
                    {
                        break;
                    }

                    var pcShootPosition = ShootManager.ComputerShoot(player, computer, battlefield, randomManager, positionParser);

                    if (allPlayerShipsPositions.Contains(pcShootPosition)) // Hit Ship
                    {
                        player.Hits.Add(new Hit(HitType.Ship, pcShootPosition));
                        shootManager.HitShip(player, computer, pcShootPosition, player.Ships, battlefield);
                    }
                    else //Hit Water
                    {
                        player.Hits.Add(new Hit(HitType.Water, pcShootPosition));
                        shootManager.HitWater(player, computer, pcShootPosition, battlefield, positionParser);
                    }

                    // Check if all Player Ship Sunken
                    if (shootManager.IsAllShipsSunken(player.Ships))
                    {
                        break;
                    }
                } while (player.Hits.Last().HitType == HitType.Ship);                                                                 // one more time shoot
            } while (shootManager.IsAllShipsSunken(computer.Ships) == false && shootManager.IsAllShipsSunken(player.Ships) == false); // End the game

            #endregion


            #region [on] 6. Game End View

            battleBgm.close();
            EndGameManager.WhoWin(player, computer, winnerBgm, shootManager);
            EndGameManager.RestartGame(winnerBgm);

            #endregion
        }