Exemple #1
0
    void LoadLevel(string levelName)
    {
        CleanupLevel();

        LevelDesc = LevelLoader.GetLevel(levelName);
        LevelLoader.LoadAndValidateLevel(LevelDesc);
        GameObjectFactory.Initialize(LevelDesc);
        Waves       = new WaveManager(LevelDesc);
        Turrets     = new TurretManager(LevelDesc);
        Projectiles = new ProjectileManager(LevelDesc);
        Utilities.Log("Creating road objects");
        GameObjectFactory.CreateMapObjects(LevelDesc);
        InitializeGameplayUISettings();

        Coin            = LevelDesc.StartingCoins;
        LivesRemaining  = LevelDesc.Lives;
        GameTime        = 0.0F;
        LastMissileTime = 0.0F;

        CountdownStartTime = GameTime;
        State = LevelState.WaveCountdown;
        Waves.AdvanceToNextWave(GameTime);
        ShowHUDUI();
        ShowCountdownUI();
    }
Exemple #2
0
    private void OnTriggerStay(Collider other)
    {
        if (other.gameObject.layer == 11)
        {
            if (Input.GetMouseButtonDown(0))
            {
                PooledObject     pooledObject = other.GetComponentInParent <PooledObject>();
                TurretManager    turret       = other.GetComponentInParent <TurretManager>();
                MineTurretScript mineTurret   = other.GetComponentInParent <MineTurretScript>();

                if (pooledObject != null)
                {
                    foreach (Transform child in other.transform.parent.transform)
                    {
                        MaterialManager childMaterial = child.GetComponent <MaterialManager>();
                        if (childMaterial != null)
                        {
                            childMaterial.DefaultMaterial();
                        }
                    }

                    pooledObject.returnToPool();
                    if (turret != null)
                    {
                        money.MoneyChange(turret.value / 2);
                    }
                    if (mineTurret != null)
                    {
                        money.MoneyChange(mineTurret.value / 2);
                    }
                }
            }
        }
    }
Exemple #3
0
    void Start()
    {
        rend       = GetComponent <Renderer>();
        startColor = rend.material.color;

        turretManager = TurretManager.instance;
    }
 public TurretNavigationMesh(Transform pMyTransform, NavMeshAgent pNavigationAgent)
 {
     this._myTransform = pMyTransform;
     this._navigationAgent = pNavigationAgent;
     this._walkSound = (AudioClip)Resources.Load("Sounds/Enemies/Turret/Walk");
     this._turretManagerScript = this._myTransform.GetComponent<TurretManager>();
 }
Exemple #5
0
    // Start is called before the first frame update
    void Start()
    {
        GameObject    turret = GameObject.Find("Manager");
        TurretManager tm     = turret.GetComponent <TurretManager>();

        remainingFriendly = tm.FriendlySaveToWin;
    }
Exemple #6
0
 // Start is called before the first frame update
 void Start()
 {
     theTurretMnager  = FindObjectOfType <TurretManager>();
     costToUpgrade    = (int)GetComponent <TowerLevel>().upgradeCost;
     costWhenSold     = (int)GetComponent <TowerLevel>().sell;
     costToReposition = (int)GetComponent <TowerLevel>().repoCost;
 }
Exemple #7
0
    /* Thoughts about method for choosing turret placement:
     * Create a new script to place on buttons. It holds a cost and a prefab.
     * Have a function that takes that script as an argument.
     * Put that function in the button OnClick() and drag the button gameobject itself in.
     * The function gets the cost and prefab that way--from the script given as an argument.
     * void SelectTurretToBuild (TurretInfo turretInfo) {
     *      cost = turretInfo.cost;
     *      turret = turretInfo.turretPrefab;
     * }
     *
     * public class TurretInfo : MonoBehaviour {
     *      public int cost;
     *      public GameObject turretPrefab;
     * }
     */

    //Please use GameManager._instance.turretManager to reference this script
    void Start()
    {
        player           = ReInput.players.GetPlayer(0);
        instance         = this;
        turretBtnPressed = false;
        canPlace         = false;
    }
Exemple #8
0
    // Update is called once per frame
    void Update()
    {
        GameObject turret = GameObject.Find("Turret(Clone)");

        if (turret == null)
        {
            turret = GameObject.Find("Turret Hard(Clone)");
        }
        if (turret == null)
        {
            GameObject    manager = GameObject.Find("Manager");
            TurretManager tm      = manager.GetComponent <TurretManager>();
            rfText.text = "Friend Left to Save: 0";
            fsText.text = "Friendly Killed: 0";
            if (tm.gameEndState == "You Won")
            {
                gameEndText.color = Color.blue;
            }
            else
            {
                gameEndText.color = Color.red;
            }
            gameEndText.text = tm.gameEndState;
        }
        else
        {
            Turret t = turret.GetComponent <Turret>();
            rfText.text      = "Friend Left to Save: " + (remainingFriendly - t.friendlySaved);
            fsText.text      = "Friendly Killed: " + t.friendlyKilled;
            gameEndText.text = "";
        }
    }
Exemple #9
0
    public void Move()
    {
        GameObject    manager  = GameObject.Find("Manager");
        TurretManager tm       = manager.GetComponent <TurretManager>();
        Vector3       moveVect = transform.forward * tm.FriendlySpeed * Time.deltaTime;

        mRigidbody.MovePosition(mRigidbody.position + moveVect);

        GameObject turret = GameObject.Find("Turret(Clone)");

        if (turret == null)
        {
            turret = GameObject.Find("Turret Hard(Clone)");
        }
        float distance = Vector3.Distance(this.transform.position, turret.transform.position);

        // -1.5 for the turret size
        if (distance - 1.5 <= tm.reachDistance)
        {
            Turret t = turret.GetComponent <Turret>();
            t.FriendlySaved();
            GameObject unitAnimation = Instantiate(_unitEntered, transform.position, transform.rotation);
            Destroy(unitAnimation, 1);
            Destroy(gameObject);
        }
    }
 private void Start()
 {
     monsterManager      = FindObjectOfType <MonsterManager>();
     correspondingTurret = transform.parent.GetComponentInParent <Turret>();
     turretManager       = FindObjectOfType <TurretManager>();
     camera = FindObjectOfType <Camera>();
 }
Exemple #11
0
 void Start()
 {
     InitializeLists();
     turretManager = TurretManager.singleton;
     turretDisplayRenderTexture = turretDisplayRenderTextureImage.texture as RenderTexture;
     turretInfoPanel.SetActive(false);
     HideAllTurretDisplays();
 }
    // Start is called before the first frame update
    void Start()
    {
        mRigidbody = GetComponent <Rigidbody>();
        GameObject    manager = GameObject.Find("Manager");
        TurretManager tm      = manager.GetComponent <TurretManager>();

        health = tm.customHealth;
    }
Exemple #13
0
 void Start()
 {
     //InvokeRepeating("CheckEnemy", 0, 0.5f);
     turretManager        = FindObjectOfType <TurretManager>();
     agent                = GetComponent <NavMeshAgent>();
     anim                 = GetComponentInChildren <Animator>();
     agent.updateRotation = true;
     //agent.speed = moveSpeed;
 }
 // Start is called before the first frame update
 void Start()
 {
     radialMenu = GameObject.Find("Turret Placement UI");
     radialMenu.SetActive(true);
     manager         = FindObjectOfType <TurretManager>();
     buildButtonText = GameObject.FindGameObjectWithTag("BuildCost").GetComponent <Text>();
     radialMenu.SetActive(false);
     mm = FindObjectOfType <MoneyManager>();
 }
Exemple #15
0
        public WaveSimulatorDamageStats SimulateDamageToEnemies(
            EnemyDescription enemy,
            WaveSolution solution,
            float HandMissileFreqency,
            float HandMissileDamantPctAverage,
            int enemyCount,
            bool invincible)
        {
            DamageStats       = new WaveSimulatorDamageStats();
            InvincibleEnemies = invincible;

            float waveTime  = 0.0F;
            float timeDelta = 1.0F / 72.0F;
            float previousHandMissileTime = 0.0f;

            EnemyWave waveDesc = new EnemyWave();

            waveDesc.Count = enemyCount;
            waveDesc.Enemy = enemy.Name;
            waveDesc.DifficultyMultiplier = 1.0F;

            ResetLevelDescState(LevelDesc);
            TurretManager     turrets     = new TurretManager(LevelDesc);
            ProjectileManager projectiles = new ProjectileManager(LevelDesc, LevelManager.LookupProjectile);
            WaveInstance      wave        = new WaveInstance(LevelDesc, waveDesc, enemy, 0.0F, SimulatorDamageCallback);

            for (int i = 0; i < solution.Turrets.Count; i++)
            {
                turrets.AddTurret(LevelManager.LookupTurret(solution.Turrets[i].Name), solution.Turrets[i].pos, projectiles);
            }

            Debug.Log("----------------------------------------");
            Debug.Log("   Wave of " + enemyCount + " " + enemy.Name + "s");
            Debug.Log("----------------------------------------");

            do
            {
                wave.Advance(waveTime);
                projectiles.AdvanceAll(waveTime);
                turrets.Fire(waveTime);

                float timeSinceLastHandMissile = waveTime - previousHandMissileTime;

                if (timeSinceLastHandMissile >= HandMissileFreqency)
                {
                    // Real projectiles have to incur flight time but we'll simulate
                    // the damage as instanntaneous to keep it simple.  Also real projectiles
                    // have blast radius that should hit multiple enemies. We'll just hit one.
                }

                waveTime += timeDelta;
            } while (!wave.IsCompleted);

            DamageStats.DamagePerEnemy = DamageStats.DamageDealt / enemyCount;

            return(DamageStats);
        }
 void Awake()
 {
     if (instance != null)
     {
         Debug.LogError("More than one BuildManager in scene!");
         return;
     }
     instance = this;
 }
Exemple #17
0
    void Awake()
    {
        if (singleton != null)
        {
            Debug.LogError("Multiple TurretManagers");
            return;
        }

        singleton = this;
    }
        // Use this for initialization
        protected override void Start()
        {
            _turretManager    = TurretManager.Instance;
            _turretManagerRpc = TurretManagerRpcClient.Instance;
            GameObject cameraGo;

            RTS_Camera.CameraDictionary.TryGetValue(CameraName, out cameraGo);
            _camera = cameraGo.GetComponent <Camera>();
            SetButton("ButtonBack", Button_Back, "");
        }
    /*[Header("Tray")]
     * public Vector3 basicTraySpawnPoint;
     * public Vector3 slowTraySpawnPoint;
     * public Vector3 rocketTraySpawnPoint;*/



    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }
    }
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.Alpha3))
     {
         TurretManager.UnlockAt(2);
     }
     else if (Input.GetKeyDown(KeyCode.Alpha4))
     {
         TurretManager.UnlockAt(3);
     }
 }
 void Awake()
 {
     if (singleton == null)
     {
         singleton = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Exemple #22
0
    void Start()
    {
        GameEvents.current.onIncreaseMoney += (int money) => this.playerMoney += money;
        GameEvents.current.onDecreaseMoney += (int money) => {
            this.playerMoney -= money;
            this.decreaseMoneyPS.Play();
        };

        this.turretManager             = GetComponent <TurretManager>();
        this.timeOfPreviousBasicIncome = 0;
    }
Exemple #23
0
    public void MountTurret(Vector3 position, TurretManager _turret)
    {
        MovementSpeed = 0;

        transform.position = position;

        GameManager.singleton.OnMountingTurret();

        _mountTurret = _turret;

        _mountTurret.ActivateTurret();
    }
Exemple #24
0
    // Start is called before the first frame update
    void Start()
    {
        tm = this;

        path = GameObject.Find("Path").GetComponent <Path>();

        CannonTurret = Resources.Load <GameObject>("Prefabs/CannonTurret");//(GameObject)Resources.Load("Assets /Prefabs/CannonTurret.prefab", typeof(GameObject));
        RocketTurret = Resources.Load <GameObject>("Prefabs/RocketTurret");
        FlameTurret  = Resources.Load <GameObject>("Prefabs/FlameTurret");
        BananaTurret = Resources.Load <GameObject>("Prefabs/BananaTurret");
        CSharpTurret = Resources.Load <GameObject>("Prefabs/CSharpTurret");
        //selectedTurret = RocketTurret;
    }
Exemple #25
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        //DontDestroyOnLoad(gameObject);
    }
Exemple #26
0
        private void Init()
        {
            permission.RegisterPermission(PermUse, this);
            permission.RegisterPermission(PermUseRadius, this);
            permission.RegisterPermission(PermUseSamRadius, this);

            cmd.AddChatCommand(_config.ToggleCommand, this, nameof(TurretCommand));
            cmd.AddChatCommand(_config.ToggleTcCommand, this, nameof(ToggleTurretsInTc));
            cmd.AddChatCommand(_config.ToggleSamTcCommand, this, nameof(ToggleSamsInTc));

            _instance      = this;
            _stored        = Interface.Oxide.DataFileSystem.ReadObject <PluginData>(Name);
            _turretManager = new TurretManager();
        }
    protected void Start()
    {
        position           = new Vector2Int((int)Mathf.Floor(transform.position.x), (int)Mathf.Floor(transform.position.y));
        transform.position = new Vector2(position.x + .5f, position.y + .5f);

        monsterManager  = FindObjectOfType <MonsterManager>();
        turretManager   = FindObjectOfType <TurretManager>();
        cameraManager   = FindObjectOfType <CameraManager>();
        upgradeButton   = turretMenu.transform.Find("UpgradeButton").GetComponent <UpgradeButton>();
        upgradeCostText = upgradeButton.transform.Find("UpgradeCost").GetComponent <Text>();
        sellButton      = turretMenu.transform.Find("SellButton").GetComponent <SellButton>();
        sellPriceText   = sellButton.transform.Find("SellPrice").GetComponent <Text>();
        UpdateButtons();
    }
        // Update is called once per frame
        protected override void Update()
        {
            #region Find the Managers.

            if (!_turretManagerRpc)
            {
                _turretManagerRpc = TurretManagerRpcClient.Instance;
                return;
            }

            if (!_turretManager)
            {
                _turretManager = TurretManager.Instance;
            }

            #endregion

            RaycastHit hit;

            var ray = _camera.ScreenPointToRay(Input.mousePosition);
            if (Input.GetKeyDown("1"))
            {
                Button_Back("");
                return;
            }

            if (!Physics.Raycast(ray, out hit, Mathf.Infinity))
            {
                return;
            }
            if (hit.transform.tag != "Platform")
            {
                return;
            }
            _turretManager.ShowTurretShadow(CurrentSpawningTurret, TeamGroup, hit.point);

            if (Input.GetMouseButtonDown(0))
            {
                if (hit.transform.tag == "Platform")
                {
                    int turretNumber;
                    if (!TurretDictionary.Instance.TurretNameToId.TryGetValue(CurrentSpawningTurret, out turretNumber))
                    {
                        return;
                    }
                    _turretManagerRpc.TurretSpawnSendRpc((int)turretNumber, TeamGroup, hit.point);
                }
            }
        }
        private void Init()
        {
            config        = Config.ReadObject <Configuration>();
            data          = Interface.Oxide.DataFileSystem.ReadObject <Data>(Name);
            turretManager = new TurretManager();
            Instance      = this;

            permission.RegisterPermission(permUse, this);
            permission.RegisterPermission(permUseRadius, this);
            permission.RegisterPermission(permUseSamRadius, this);

            cmd.AddChatCommand(config.ToggleCommand, this, "TurretCommand");
            cmd.AddChatCommand(config.ToggleTCCommand, this, "ToggleTurretsInTc");
            cmd.AddChatCommand(config.ToggleSamTcCommand, this, "ToggleSamsInTc");
        }
Exemple #30
0
 public void FriendlyKilled()
 {
     if (mState != State.INACTIVE || mState != State.DEATH || mState != State.WON)
     {
         friendlyKilled++;
         mTurretAgent.AddReward(-1.0f);
         GameObject    manager = GameObject.Find("Manager");
         TurretManager tm      = manager.GetComponent <TurretManager>();
         if (friendlyKilled >= tm.FriendlyKilledToLose)
         {
             tm.gameEndState = "You Lost";
             state           = State.DEATH;
         }
     }
 }
    // Start is called before the first frame update
    void Start()
    {
        TurretManager turrets = Instantiate(turretManager, transform);

        turrets.name = "TurretManager";
        hordes       = Instantiate(hordeManager, transform);
        hordes.name  = "HordeManager";
        GridManager grid = Instantiate(gridManager, transform);

        grid.name = "GridManager";
        WallManager walls = Instantiate(wallManager, transform);

        walls.name = "WallManager";

        SpawnWave(waveCount);
    }
Exemple #32
0
        /// <summary>
        /// Load all initial game logic.
        /// </summary>
        private void InitializeGame()
        {
            this.gameState = GameState.Start;

            player = TurretManager.spawnTurret(TurretType.Basic, Vector3.Empty, Vector3.Empty, new Vector3(1f, 1f, 1f), keyboard);
            this.camera = new ThirdPersonCamera(player, new Vector3(0f, 10f, -15f));
            player.Head.addChild(camera);

            List<Wave> waves = new List<Wave>();
            for (int i = 1; i <= 10; i++)
            {
                Wave wave = new Wave();
                wave.waveNumber = i;
                wave.enemiesPerSpawn = i;
                wave.planeSpeed = 5f + i * 2;
                wave.planeTurnSpeed = (float)(Math.PI / 8);
                wave.tankSpeed = 5f + i;
                wave.tankTurnSpeed = (float)(Math.PI / 8);
                wave.planesToSpawn = (int)(i / 2);
                wave.tanksToSpawn = (int)(i / 2) + (i % 2);
                wave.spawnDelay = 1f + i;
                wave.minimumSpawnDistance = 150f;
                wave.maximumSpawnDistance = 200f;
                waves.Add(wave);
            }

            managers = new List<Manager>();
            BulletManager bulletManager = new BulletManager();
            managers.Add(bulletManager);
            TurretManager turretManager = new TurretManager();
            managers.Add(turretManager);
            EnemyManager enemyManager = new EnemyManager(waves, 0);
            managers.Add(enemyManager);
            ParticleEmitterManager particleEmitterManager = new ParticleEmitterManager(camera);
            managers.Add(particleEmitterManager);

            world = new WorldBox(
                ContentLoader.WorldBoxTop,
                ContentLoader.WorldBoxBottom,
                ContentLoader.WorldBoxLeft,
                ContentLoader.WorldBoxRight,
                ContentLoader.WorldBoxFront,
                ContentLoader.WorldBoxBack);

            // TODO: make the gui redraw based on the window size
            gui = new GUI(player,
                new Rectangle(this.Width - (int)(this.Width * 0.0625),
                (int)(this.Height * 0.0052),
                (int)(this.Width * 0.0521),
                (int)(this.Height * 0.0104)),
                new Point(this.Width - (int)(this.Width * 0.183), 0),
                device, this.Width, this.Height);
        }