Ejemplo n.º 1
0
    } // hàm thay đổi hình ảnh súng

    public static void ChangeGun(Player player) // hàm gọi class cannon thay đổi súng
    {
        if (player.WatchBullet() >= 150)
        {
            CannonManager.ChangeGunPrefabs(player, 6);
        }
        else if (player.WatchBullet() >= 125)
        {
            CannonManager.ChangeGunPrefabs(player, 5);
        }
        else if (player.WatchBullet() >= 100)
        {
            CannonManager.ChangeGunPrefabs(player, 4);
        }
        else if (player.WatchBullet() >= 75)
        {
            CannonManager.ChangeGunPrefabs(player, 3);
        }
        else if (player.WatchBullet() >= 50)
        {
            CannonManager.ChangeGunPrefabs(player, 2);
        }
        else if (player.WatchBullet() >= 25)
        {
            CannonManager.ChangeGunPrefabs(player, 1);
        }
        else
        {
            CannonManager.ChangeGunPrefabs(player, 0);
        }
    }
Ejemplo n.º 2
0
    Vector3[] GetDepotPositions(GameObject player)
    {
        DeckManager   deckManager   = player.GetComponent <DeckManager> ();
        CannonManager cannonManager = player.GetComponent <CannonManager> ();

        Vector3[] result   = new Vector3[cannonManager.cannonNumber];
        float[]   xPosUsed = new float[cannonManager.cannonNumber];
        float     zPos     = 0;

        if (player == player1)
        {
            zPos = deckManager.deckHeight - (deckManager.deckHeight);
        }
        else if (player == player2)
        {
            zPos = player.GetComponent <Player> ().posOffsetZ + (deckManager.deckHeight - 1);
        }

        for (int i = 0; i < result.Length; i++)
        {
            float newX = GetRandomX(player, xPosUsed);
            xPosUsed [i] = newX;
            result [i]   = new Vector3(newX, 0, zPos);
        }

        return(result);
    }
    // Use this for initialization
    void Start()
    {
        ax = 0;
        //Find GameObject
        generator = GameObject.FindObjectOfType <Generator>();
        Manager   = GameObject.FindObjectOfType <CannonManager>();
        isLeft    = Manager.isLeft;

        radius = gameObject.GetComponent <SpriteRenderer>().bounds.size.x / 2;

        //Initiate cannonball velocity and accelerations
        if (isLeft)
        {
            initialv = Manager.muzzle1 / 100f;
            angle    = Manager.angle1;
            vx       = initialv * Mathf.Cos(angle * Mathf.Deg2Rad);
            vy       = initialv * Mathf.Sin(angle * Mathf.Deg2Rad);
        }
        else
        {
            initialv = Manager.muzzle2 / 100f;
            angle    = Manager.angle2;
            vx       = -initialv *Mathf.Cos(angle *Mathf.Deg2Rad);

            vy = initialv * Mathf.Sin(angle * Mathf.Deg2Rad);
        }
        ay = -0.00098f;
    }
Ejemplo n.º 4
0
 private void Start()
 {
     SelectionImage         = GetComponent <Image>();
     Cannon                 = CannonManager.instance;
     SelectionImage.enabled = false;
     if (IsEnabled)
     {
         Screen.SetActive(IsEnabled);
         Image.SetActive(!IsEnabled);
     }
     else
     {
         if (!IsBlank)
         {
             Screen.SetActive(IsEnabled);
             Image.SetActive(!IsEnabled);
         }
         else
         {
             Screen.SetActive(IsEnabled);
         }
     }
     //StartCoroutine(SpawnItem());
     SpawnItemAnim();
 }
Ejemplo n.º 5
0
 private void Awake()
 {
     gameState = CoffeeMakerGameState.Pending;
     if (instance == null)
     {
         instance = this;
     }
 }
Ejemplo n.º 6
0
 private void Start()
 {
     cannonManager = transform.parent.GetComponent <CannonManager>();
     if (cannonManager == null)
     {
         print("can't find cannon Manager");
     }
 }
Ejemplo n.º 7
0
        public MapEditor(GameWindow window, ClientNetworking client, CannonManager cannonManager, List <CannonGroups> cannonGroups)
        {
            factory = GameObjectFactory.Instance;

            this.window        = window;
            this.client        = client;
            this.cannonManager = cannonManager;
            this.cannonGroups  = cannonGroups;
        }
Ejemplo n.º 8
0
 private void Start()
 {
     myImage = GetComponent <Image>();
     Cannon  = CannonManager.instance;
     if (!isLoading)
     {
         LoadingBar = transform.GetChild(0).GetComponent <Image>();
     }
 }
Ejemplo n.º 9
0
    public void SetUpCannon()
    {
        CannonManager cannonManager = activePlayer.GetComponent <CannonManager> ();

        if (cannonManager.cannonsCreated < cannonManager.cannonNumber)
        {
            cannonToDeploy = cannonManager.CreateCannon(this.transform);
        }
    }
Ejemplo n.º 10
0
 void Start()
 {
     //creates the cannon manager singleton.
     CannonManager_script = CannonManager.S;
     //gets the renderer of this building spot.
     rendr = GetComponent <Renderer>();
     //save the original color information.
     original_color = rendr.material.color;
 }
Ejemplo n.º 11
0
        public MapEditor(GameWindow window, ClientNetworking client, CannonManager cannonManager, List <CannonGroups> cannonGroups, int screenconfiguration)
        {
            factory = GameObjectFactory.Instance;

            this.window              = window;
            this.client              = client;
            this.cannonManager       = cannonManager;
            this.cannonGroups        = cannonGroups;
            this.screenconfiguration = screenconfiguration;
        }
Ejemplo n.º 12
0
    void Awake()
    {
        AudioManager.AddTracks(new Dictionary <string, string> {
            { "MenuMusic", "Ponies_and_Balloons" },
            { "GamePlayMusic", "Racing_The_Clock" }
        });

        InputManager  = GetComponent <InputManager>();
        CannonManager = GetComponent <CannonManager>();
    }
Ejemplo n.º 13
0
    public GamePlayState(InputManager inputManager, CannonManager cannonManager, GameData gameData)
    {
        InputManager  = inputManager;
        CannonManager = cannonManager;
        GameData      = gameData;

        GamePlayUIGroup = GameObject.Find("Canvas/GamePlayUI").GetComponent <CanvasGroup>();
        ClockText       = GameObject.Find("Canvas/GamePlayUI/Clock").GetComponent <Text>();
        ScoreText       = GameObject.Find("Canvas/GamePlayUI/Score").GetComponent <Text>();

        GameTimer = new Timer(146);
        DifficultyIncreaseTimer = new Timer(GameTimer.Delay / ((MaxDifficulty - MinDifficulty + DifficultyStep) / DifficultyStep));
    }
Ejemplo n.º 14
0
 public static void GetKeyToChangeBullet(Player player, KeyCode SubKey, KeyCode AddKey)
 {
     if (Input.GetKeyDown(SubKey))
     {
         player.SubBulletValue(5);
         CannonManager.ChangeGun(player);
         Debug.Log("player" + player.WatchBullet());
     }
     if (Input.GetKeyDown(AddKey))
     {
         player.AddBulletValue(5);
         CannonManager.ChangeGun(player);
         Debug.Log("player" + player.WatchBullet());
     }
 } // hàm tăng giảm dame của đạn
Ejemplo n.º 15
0
    void CreateCannons(GameObject player)
    {
        DeckManager   deckManager   = player.GetComponent <DeckManager> ();
        CannonManager cannonManager = player.GetComponent <CannonManager> ();

        Vector3[] positions = GetCannonPositions(player);

        for (int i = 0; i < cannonManager.cannonNumber; i++)
        {
            GameObject cannonToDeploy = cannonManager.CreateCannon(player.transform);
            int        xPos           = (int)positions [i].x;
            int        zPos           = (int)positions [i].z;
            cannonToDeploy.GetComponent <Cannon>().PlaceCannon(deckManager.RetrieveTile(xPos, zPos));
            cannonManager.cannonsCreated += 1;
        }
    }
Ejemplo n.º 16
0
    // Update is called once per frame
    void Update()
    {
        CannonManager.GetKeyToControl(0, KeyCode.Q, KeyCode.W);
        CannonManager.GetKeyToControl(1, KeyCode.E, KeyCode.R);
        CannonManager.GetKeyToControl(2, KeyCode.T, KeyCode.Y);
        CannonManager.GetKeyToControl(3, KeyCode.U, KeyCode.I);


        BulletManager.GetKeyToChangeBullet(PlayerManager.player[0], KeyCode.A, KeyCode.S);
        BulletManager.GetKeyToChangeBullet(PlayerManager.player[1], KeyCode.D, KeyCode.F);
        BulletManager.GetKeyToChangeBullet(PlayerManager.player[2], KeyCode.G, KeyCode.H);
        BulletManager.GetKeyToChangeBullet(PlayerManager.player[3], KeyCode.J, KeyCode.K);

        BulletManager.GetKeyToShoot(0, PlayerManager.player[0], KeyCode.Alpha1);
        BulletManager.GetKeyToShoot(1, PlayerManager.player[1], KeyCode.Alpha2);
        BulletManager.GetKeyToShoot(2, PlayerManager.player[2], KeyCode.Alpha3);
        BulletManager.GetKeyToShoot(3, PlayerManager.player[3], KeyCode.Alpha4);
    }
Ejemplo n.º 17
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            GameWorld.Initialize(0, 5700, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height, new Vector2(0, 9.8f));
            GameWorld.ViewPortXOffset = 0;

            SpriteCreators.Load("Content\\spritesheet.txt");

            // Create the texture manager
            textureManager = new TextureManager(Content);

            // Now load the sprite creator factory helper
            factory = GameObjectFactory.Instance;
            factory.Initialize(textureManager);

            cannonManager = new CannonManager();
            cannonGroups  = new List <CannonGroups>();

            client = new ClientNetworking();
            client.Connect();
            client.ActionHandler["shoot"]  = new EventHandler(this.HandleNetworkShoot);
            client.ActionHandler["create"] = new EventHandler(this.HandleNetworkCreate);

            // Add a few sprite creators
            factory.AddCreator((int)GameObjectTypes.CAT, SpriteCreators.CreateCat);
            factory.AddCreator((int)GameObjectTypes.DOG, SpriteCreators.CreateDog);
            factory.AddCreator((int)GameObjectTypes.BOOM, SpriteCreators.CreateBoom);
            factory.AddCreator((int)GameObjectTypes.WOOD1, SpriteCreators.CreateWood1);
            factory.AddCreator((int)GameObjectTypes.WOOD2, SpriteCreators.CreateWood2);
            factory.AddCreator((int)GameObjectTypes.WOOD3, SpriteCreators.CreateWood3);
            factory.AddCreator((int)GameObjectTypes.WOOD4, SpriteCreators.CreateWood4);
            factory.AddCreator((int)GameObjectTypes.PLATFORM_LEFT, SpriteCreators.CreatePlatformLeft);
            factory.AddCreator((int)GameObjectTypes.PLATFORM_MIDDLE, SpriteCreators.CreatePlatformMiddle);
            factory.AddCreator((int)GameObjectTypes.PLATFORM_RIGHT, SpriteCreators.CreatePlatformRight);
            factory.AddCreator((int)GameObjectTypes.CANNON, SpriteCreators.CreateCannon);
            factory.AddCreator((int)GameObjectTypes.CANNONWHEEL, SpriteCreators.CreateCannonWheel);
            factory.AddCreator((int)GameObjectTypes.POWERMETERBAR, SpriteCreators.CreatePowerMeterBar);
            factory.AddCreator((int)GameObjectTypes.POWERMETERTAB, SpriteCreators.CreatePowerMeterTab);

            mapEditor = new MapEditor(Window, client, cannonManager, cannonGroups);

            base.Initialize();
        }
Ejemplo n.º 18
0
    void Start()
    {
        compass     = GameObject.Find("Compass").GetComponent <Compass>();
        gameManager = GameObject.FindObjectOfType <GameManager>().GetComponent <GameManager>();
        animator    = GetComponent <NetworkAnimator>();

        foreach (SkinnedMeshRenderer renderer in GetComponentsInChildren <SkinnedMeshRenderer>())
        {
            if (renderer.name == "Sails")
            {
                sailRenderer = renderer;
            }
        }

        spawnPoint = transform.position;

        foreach (CannonManager cannonManager in GetComponentsInChildren <CannonManager>())
        {
            if (cannonManager.name == "Port Cannons")
            {
                portCannons = cannonManager;
            }
            else
            {
                starboardCannons = cannonManager;
            }
        }

        if (isLocalPlayer)
        {
            playerFlag = PlayerPrefsManager.GetPlayerFlag(); //PlayerPrefs.GetInt("player_flag");
            CmdSetFlag(playerFlag);

            foreach (Player player in GameObject.FindObjectsOfType <Player>())
            {
                if (!player.isLocalPlayer)
                {
                    player.RpcUpdateFlag();
                }
            }
            //CmdUpdateFlag(PlayerPrefs.GetInt("player_flag"));
        }
    }
Ejemplo n.º 19
0
    void Update()
    {
        DepotManager  depotManager  = activePlayer.GetComponent <DepotManager> ();
        CannonManager cannonManager = activePlayer.GetComponent <CannonManager> ();
        PirateManager pirateManager = activePlayer.GetComponent <PirateManager> ();

        cannons.text    = cannonManager.cannonsCreated.ToString();
        pirates.text    = activePlayer.GetComponent <PirateManager> ().piratesCreated.ToString();
        ammoDepots.text = depotManager.ammoDepotsCreated.ToString();
        woodDepots.text = depotManager.woodDepotsCreated.ToString();

        if (!buildingDone)
        {
            if (playerOne.GetComponent <PirateManager>().BuildUpDone() && playerOne.GetComponent <CannonManager>().BuildUpDone() && playerOne.GetComponent <DepotManager>().BuildUpDone())
            {
                if (playerTwo.GetComponent <PirateManager>().BuildUpDone() && playerTwo.GetComponent <CannonManager>().BuildUpDone() && playerTwo.GetComponent <DepotManager>().BuildUpDone())
                {
                    buildingDone = true;
                    GetComponent <GameManager> ().EndBuildPhase();
                }
            }
        }
    }
Ejemplo n.º 20
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            GameWorld.Initialize(0, 12234 - (1080 * 2), this.Window.ClientBounds.Width, this.Window.ClientBounds.Height, new Vector2(0, 9.8f));
            GameWorld.ViewPortXOffset = 0;

            SpriteCreators.Load("Content\\spritesheet.txt");

            MapLoaded = false;

            // Create the texture manager
            textureManager = new TextureManager(Content);

            //Create the audio manager
            AudioManager.Instance.Initialize(Content);


            // Now load the sprite creator factory helper
            factory = GameObjectFactory.Instance;
            factory.Initialize(textureManager);

            cannonManager = new CannonManager();
            cannonGroups  = new List <CannonGroups>();


            client = new ClientNetworking();
            client.Connect();
            client.ActionHandler["shoot"]       = new EventHandler(this.HandleNetworkShoot);
            client.ActionHandler["create"]      = new EventHandler(this.HandleNetworkCreate);
            client.ActionHandler["plane"]       = new EventHandler(this.HandleNetworkPlane);
            client.ActionHandler["createother"] = new EventHandler(this.HandleNetworkCreateOtherStuff);
            client.ActionHandler["reset"]       = new EventHandler(this.HandleReset);
            client.ActionHandler["endgame"]     = new EventHandler(this.HandleEndGame);
            client.ActionHandler["sendpoints"]  = new EventHandler(this.HandleSendPoints);

            // Add a few sprite creators
            factory.AddCreator((int)GameObjectTypes.CAT, SpriteCreators.CreateCat);
            factory.AddCreator((int)GameObjectTypes.DOG, SpriteCreators.CreateDog);
            factory.AddCreator((int)GameObjectTypes.SUN, SpriteCreators.CreateSun);
            factory.AddCreator((int)GameObjectTypes.BOOM, SpriteCreators.CreateBoom);
            factory.AddCreator((int)GameObjectTypes.PUFF, SpriteCreators.CreatePuff);
            factory.AddCreator((int)GameObjectTypes.DINO, SpriteCreators.CreateDino);
            factory.AddCreator((int)GameObjectTypes.CLOUD1, SpriteCreators.CreateCloud1);
            factory.AddCreator((int)GameObjectTypes.CLOUD2, SpriteCreators.CreateCloud2);
            factory.AddCreator((int)GameObjectTypes.CLOUD3, SpriteCreators.CreateCloud3);
            factory.AddCreator((int)GameObjectTypes.CLOUD4, SpriteCreators.CreateCloud4);
            factory.AddCreator((int)GameObjectTypes.CLOUD5, SpriteCreators.CreateCloud5);
            factory.AddCreator((int)GameObjectTypes.CLOUD6, SpriteCreators.CreateCloud6);
            factory.AddCreator((int)GameObjectTypes.WOOD1, SpriteCreators.CreateWood1);
            factory.AddCreator((int)GameObjectTypes.WOOD2, SpriteCreators.CreateWood2);
            factory.AddCreator((int)GameObjectTypes.WOOD3, SpriteCreators.CreateWood3);
            factory.AddCreator((int)GameObjectTypes.WOOD4, SpriteCreators.CreateWood4);
            factory.AddCreator((int)GameObjectTypes.PLATFORM_LEFT, SpriteCreators.CreatePlatformLeft);
            factory.AddCreator((int)GameObjectTypes.PLATFORM_MIDDLE, SpriteCreators.CreatePlatformMiddle);
            factory.AddCreator((int)GameObjectTypes.PLATFORM_RIGHT, SpriteCreators.CreatePlatformRight);
            factory.AddCreator((int)GameObjectTypes.CANNON, SpriteCreators.CreateCannon);
            factory.AddCreator((int)GameObjectTypes.CANNONWHEEL, SpriteCreators.CreateCannonWheel);
            factory.AddCreator((int)GameObjectTypes.POWERMETERBAR, SpriteCreators.CreatePowerMeterBar);
            factory.AddCreator((int)GameObjectTypes.POWERMETERTAB, SpriteCreators.CreatePowerMeterTab);
            factory.AddCreator((int)GameObjectTypes.EXPLOSION1, SpriteCreators.CreateExplosion1);
            factory.AddCreator((int)GameObjectTypes.EXPLOSION1, SpriteCreators.CreateExplosion2);
            factory.AddCreator((int)GameObjectTypes.PLANE, SpriteCreators.CreatePlane);
            factory.AddCreator((int)GameObjectTypes.CATSPLODE, SpriteCreators.CreateCatsplode);
            factory.AddCreator((int)GameObjectTypes.DUSTSPLODE, SpriteCreators.CreateDustsplode);
            factory.AddCreator((int)GameObjectTypes.YOULOSE, SpriteCreators.CreateYouLose);
            factory.AddCreator((int)GameObjectTypes.YOUWIN, SpriteCreators.CreateYouWin);
            factory.AddCreator((int)GameObjectTypes.SCOREPLUS50, SpriteCreators.CreatePlus50);
            factory.AddCreator((int)GameObjectTypes.SCOREPLUS100, SpriteCreators.CreatePlus100);
            factory.AddCreator((int)GameObjectTypes.SCOREPLUS250, SpriteCreators.CreatePlus250);

            //factory.AddCreator((int)GameObjectTypes.EAHSCSLOGO, SpriteCreators.CreateEAHSCSLogo);

            mapEditor = new MapEditor(Window, client, cannonManager, cannonGroups, ScreenConfiguration);

            base.Initialize();
        }
Ejemplo n.º 21
0
 void Awake()
 {
     S = this;
 }
Ejemplo n.º 22
0
 private void Awake()
 {
     instance  = this;
     isEnabled = true;
 }