コード例 #1
0
ファイル: Ship.cs プロジェクト: TerriFin/2dSpaceDemo
    private void Start()
    {
        Cargo     = GetComponent <MetalCargo>();
        Hitpoints = GetComponent <Hitpoints>();

        ShipsManager.AddShip(this);
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        _currentScene = SceneManager.GetActiveScene().name;


        if (_currentScene == Constants.CONNECTION_SCENE)
        {
            ActivePlayers = NetworkServer.connections.Count <= 0 ? 0 : NetworkServer.connections.Count - 1;
            //ActivePlayers = Network.connections.Length;

            _activePlayersText.text = ActivePlayers.ToString();

            _IPText.text = Network.player.ipAddress;

            //_statusText.text = Network.isServer.ToString();
        }

        if (_currentScene == Constants.GAMEPLAY_SCENE)
        {
            if (_justLoaded)
            {
                _shipsManager = FindObjectOfType <ShipsManager>();

                _shipsManager.InstantiateShips(ActivePlayers, playersChoices.ToArray <Choice>());

                _justLoaded = false;
            }
        }
    }
コード例 #3
0
ファイル: TimingManager.cs プロジェクト: TerriFin/2dSpaceDemo
 private void Awake()
 {
     FactionsManager.SetFactions();
     RelationshipManager.InitializeRelations();
     ShipsManager.SetFactions();
     BuildingsManager.SetFactions();
 }
コード例 #4
0
 private void Init()
 {
     Sea          = new Sea(this);
     ShipsManager = new ShipsManager(Sea);
     Computer     = new Computer(Sea);
     Human        = new Human();
     Panel.Controls.Clear();
     ShipsManager.CreateShips();
     AddTilesToPanel();
 }
    // Use this for initialization
    void Start()
    {
        _shipsManager  = FindObjectOfType <ShipsManager>();
        playersChoices = new Ships[ActivePlayers];

        for (int i = 0; i < playersChoices.Length; i++)
        {
            playersChoices[i] = Ships.FAST;
        }

        _shipsManager.InstantiateShips(ActivePlayers, this.playersChoices);
    }
コード例 #6
0
 public void SetMode(StageInfo st)
 {
     stage = st;
     EventManager.ChangeShipHandler += (s) => StartGame();
     Angar.Open();
     ShipsManager.SetSelectShipMode();
     if (st.RecommendedShip)
     {
         ShipsManager.ShowRecommendedShip(st.RecommendedShip);
     }
     else
     {
         ShipsManager.ShowLastSelectedShip();
     }
 }
コード例 #7
0
ファイル: ShipsView.aspx.cs プロジェクト: msalah85/Tundra
    private void ShowShipInformation(int Id)
    {
        var result = new ShipsManager().GetShipDetails(Id);

        if (result != null)
        {
            //hfID.Value = result.ShipID.ToString();
            txtNameAr.Text = result.ShipAr;
            txtNameEn.Text = result.ShipEn;
            //txtShortDescEn.Text = result.ShipDescEn;
            //txtShortdescAr.Text = result.ShipDescAr;
            cbActive.Checked = (bool)result.Active;

            txtPriority.Text = result.Priority.ToString();
        }
    }
コード例 #8
0
ファイル: PlayScreen.cs プロジェクト: pontufle/spaceInvaders
        public PlayScreen(GameWrapper i_Game, bool i_TwoPlayers)
            : base(i_Game)
        {
            this.IsModal = true;
            this.BlendState = BlendState.NonPremultiplied;

            m_Game = i_Game;

            m_TwoPlayers = i_TwoPlayers;

            m_LoadingScreen = new LoadingScreen(i_Game, m_Level);
            m_PauseScreen = new PauseScreen(i_Game);
            m_GameOverScreen = new GameOverScreen(i_Game, new GameOverEventArgs(EventArgs.Empty));

            m_BackGround = new BackGround(this.Game as GameWrapper);
            m_BackGround.DrawOrder = 0;
            Add(m_BackGround);

            m_ShipsManager = new ShipsManager(i_Game, m_TwoPlayers);
            m_ShipsManager.DrawOrder = 10;
            m_ShipsManager.AlienHit += onGameOverRequested; // todo: if (*) is implemented then unsubscribe this
            m_ShipsManager.AllShipsDestroyed += onGameOverRequested;
            Add(m_ShipsManager);

            m_Enemies = new EnemyManager(i_Game);
            m_Enemies.DrawOrder = 10;
            m_Enemies.AliensReachedBottom += onGameOverRequested; // todo: (*) alien reached spaceships height, not bottom
            m_Enemies.AllAliensAreDead += onLevelWon;
            m_Enemies.AllAliensAreDead += playGameOverSound;
            Add(m_Enemies);

            m_ScoreBoard = new ScoreBoard(i_Game);
            m_ScoreBoard.DrawOrder = 20;
            Add(m_ScoreBoard);

            m_LivesDisplay = new LivesDisplay(i_Game);
            m_LivesDisplay.DrawOrder = 20;
            Add(m_LivesDisplay);

            m_BarriersManager = new BarriersManager(i_Game);
            m_ShipsManager.DrawOrder = 10;
            Add(m_BarriersManager);
        }
コード例 #9
0
ファイル: GamePage.cs プロジェクト: SXMXEL/BattleShip
 public void Init(
     ElementItem[,] userGrid,
     ElementItem[,] computerGrid,
     int gridSize,
     Action onSetStartPageState,
     ShipsManager shipsManager,
     List <StepMessageItem> stepMessageItems,
     SessionDataManager sessionDataManager,
     Action <PageState> setGamePage,
     Action resetGrid)
 {
     FreshStart();
     _shipsManager = shipsManager;
     _dragBlock    = _shipsManager.DragBlock;
     _resetShips   = _shipsManager.ResetShips;
     _restartButton.onClick.RemoveAllListeners();
     _restartButton.onClick.AddListener(() =>
                                        Restart(
                                            stepMessageItems,
                                            sessionDataManager,
                                            setGamePage,
                                            resetGrid));
     _backToStartMenuButton.onClick.RemoveAllListeners();
     _backToStartMenuButton.onClick.AddListener(onSetStartPageState.Invoke);
     _confirm.onClick.RemoveAllListeners();
     _confirm.onClick.AddListener(() =>
     {
         ConfirmShipsPositions();
         _shipsManager.SetRandomShips(gridSize, _shipsManager.ComputerShips, computerGrid);
     });
     _random.onClick.RemoveAllListeners();
     _random.onClick.AddListener(() =>
     {
         _shipsManager.SetRandomShipsForAll();
         ShipsContainer.SetActive(false);
         HideGameObjects.SetActive(true);
     });
     TryToActivateConfirmButton();
 }
コード例 #10
0
ファイル: Hitpoints.cs プロジェクト: TerriFin/2dSpaceDemo
    private void Update()
    {
        if (CurrentHp <= 0)
        {
            print("OBJECT: " + gameObject.name + " WAS DESTROYED!");
            Ship      attachedShip      = GetComponent <Ship>();
            Structure attachedStructure = GetComponent <Structure>();

            if (attachedShip != null)
            {
                ShipsManager.RemoveShip(attachedShip);
            }
            else if (attachedStructure != null)
            {
                BuildingsManager.RemoveBuilding(attachedStructure);
            }

            Destroy(gameObject);
        }

        if (CurrentHp < maxHp)
        {
            if (Time.time >= afterCombatHealTimer)
            {
                if (Time.time >= timeBetweenHealsTimer)
                {
                    timeBetweenHealsTimer = Time.time + timeBetweenHeals;
                    CurrentHp            += healAmount;

                    if (CurrentHp > maxHp)
                    {
                        CurrentHp = maxHp;
                    }
                }
            }
        }
    }
コード例 #11
0
ファイル: WorldManager.cs プロジェクト: nint22/NovaLegacy
    /*** Script Methods ***/
    // Use this for initialization
    void Start()
    {
        /*** Init. Game System ***/

        // Default camera zoom
        Camera.main.orthographicSize = Globals.MinCameraSize + (Globals.MaxCameraSize - Globals.MinCameraSize) / 2.0f;

        // Instantiate all game-level objects
        SManager = gameObject.AddComponent(typeof(SpriteManager)) as SpriteManager;
        ProjManager = gameObject.AddComponent(typeof(ProjectileManager)) as ProjectileManager;
        ShipManager = gameObject.AddComponent(typeof(ShipsManager)) as ShipsManager;
        SceneManager = gameObject.AddComponent(typeof(SceneryManager)) as SceneryManager;
        ResManager = gameObject.AddComponent(typeof(ResourceManager)) as ResourceManager;
        BuildingManager = gameObject.AddComponent(typeof(BuildingManager)) as BuildingManager;
        AManager = gameObject.AddComponent(typeof(AudioManager)) as AudioManager;
        SongManager = gameObject.AddComponent(typeof(AudioSystem)) as AudioSystem;
        OverlayView = gameObject.AddComponent(typeof(GameOverlay)) as GameOverlay;
        ContextMenuView = gameObject.AddComponent(typeof(GameContextMenu)) as GameContextMenu;

        /*** Background System ***/

        // Allocate the background sprites
        BackgroundSprites = new Sprite[BackgroundLayerCount];
        for(int i = 0; i < BackgroundLayerCount; i++)
        {
            // Alloc and retain
            Sprite Background = new Sprite("Textures/BGLayer" + i);
            BackgroundSprites[i] = Background;

            // Make the sprite geometry as big as the max camera, and center it on the camera
            BackgroundSprites[i].SetGeometrySize(new Vector2(Globals.MaxCameraSize, Globals.MaxCameraSize) * 2.5f * Camera.main.aspect);
            BackgroundSprites[i].SetPosition(-BackgroundSprites[i].GetGeometrySize() / 2.0f);
            BackgroundSprites[i].SetDepth(Globals.BackgroundDepth - i); // Each layet is closer to the camera

            // Register sprite
            SManager.AddSprite(Background);
        }

        /*** Add Scene Elements & Load Enemey Spawn List ***/

        // Load the level gen. (note that we finish loading in the "OnLevelWasLoaded" because
        // of a Unity3D-specific design issue
        LevelLoaded = false;
        LevelGen = new LevelManager(TargetLevel);

        /*** TESTING: Add temp ships ***/

        // Create a few ships destroyers bottom right
        for(int i = 0; i < 6; i++)
        {
            int x = UnityEngine.Random.Range(-500, 500);
            int y = UnityEngine.Random.Range(-500, 500);

            BaseShip Friendly = null;
            if(i == 0)
                Friendly = new CarrierShip();
            else if(i == 1)
                Friendly = new DestroyerShip();
            else
                Friendly = new FighterShip();
            Friendly.SetPos(new Vector2(x, y));
            ShipManager.ShipsList.Add(Friendly);
        }
    }
コード例 #12
0
 private void Awake()
 {
     currencyManager = CurrencyManager.Instance;
     shipsManager    = FindObjectOfType <ShipsManager>(); // [!!!] ShipsManager Singleton? Or Make it child of something else?
 }
コード例 #13
0
 void Awake()
 {
     sm = this;
 }
コード例 #14
0
 private void Awake()
 {
     _ship             = GetComponent <ShipsManager>();
     _weaponController = GetComponent <WeaponController>();
 }