예제 #1
0
 /// <summary>
 /// Call this method to initialize this enemy's data.
 /// </summary>
 /// <param name="path">Start paths</param>
 /// <param name="enemyFormation">Enemy main formation.</param>
 /// <param name="data">Current game data</param>
 /// <param name="enemyType">Enemy type</param>
 public override void Init(Path path, FormationController enemyFormation, GameData data, EnemyType enmEnemyType)
 {
     base.Init(path, enemyFormation, data, enmEnemyType);
     _baseBullet   = data.Bullet;
     _bulletCount  = _baseBullet;
     _lastShotTime = RateFire;
 }
예제 #2
0
	void Start () {	
		if (instance != null && instance != this) { Destroy (gameObject); } 
		else { instance = this; GameObject.DontDestroyOnLoad(gameObject); }

		if (!formation) formation = enemyFormation.GetComponent<FormationController>();
			if (!formation) Debug.Log ("formation 2 pickup error");
		frameboard = GameObject.FindWithTag("Frameboard").GetComponent<Text>();
			if (!frameboard) Debug.LogError("FAIL tag Frameboard");
		scoreboard = GameObject.FindWithTag("Scoreboard").GetComponent<Text>();
			if (!scoreboard) Debug.LogError("FAIL tag Scoreboard");
		waveboard = GameObject.FindWithTag("Waveboard").GetComponent<Text>();
			if (!waveboard) Debug.LogError("FAIL tag Waveboard");

		playerMaxHealth = 420f;
		playerHitPoints = playerMaxHealth;
		playerShipCount = playerMaxShips;
		bCredit = false;
		creditButton.gameObject.SetActive(true);
		creditMessage.gameObject.SetActive(false);
		enemyFormation.gameObject.SetActive(false);
		loseMessage.gameObject.SetActive(false);
		quitButton.gameObject.SetActive(true);
		startButton.gameObject.SetActive(true);
		startMessage.gameObject.SetActive(true);
		startOverButton.gameObject.SetActive(false);
		waveboard.gameObject.SetActive(false);
		winMessage.gameObject.SetActive(false);
		ShowMyShips();
		priorShipCount = playerShipCount;
		fps = 0.0f;
		showFramerate = true; // TODO turn off for relase
		totalFrames = 0;
		totalFrameTime = 0f;
		waveNumber = 1;
	}
예제 #3
0
 void Awake()
 {
     isInvincible        = true;
     canShoot            = true;
     scoreManager        = FindObjectOfType <ScoreManager> ();
     formationController = FindObjectOfType <FormationController> ();
     enemyHealthManager  = GetComponent <EnemyHealthManager> ();
     if (scoreManager.score <= 50)
     {
         difficulty = (scoreManager.score / 10);
     }
     else
     {
         difficulty = 5;
     }
     enemySpeed = formationController.formationSpeed + difficulty;
     if (difficulty < 3)
     {
         enemyHealthManager.enemyHealth = 1 + difficulty;
     }
     else
     {
         enemyHealthManager.enemyHealth = 3;
     }
     pauseManager  = FindObjectOfType <PauseManager> ();
     shootCooldown = 0f;
 }
예제 #4
0
    public void AddToFormation(FormationController formCon, TeamController member)
    {
        foreach (Slot slot in formCon.slots)
        {
            if (slot.character != null)
            {
                continue;
            }

            slot.character = member.transform.parent.gameObject;
            break;
        }

        GameObject teamLeader   = member.transform.parent.gameObject;
        Vector3    formationPos = formCon.formation.GetCenter();
        Vector3    formationDir = formationPos - teamLeader.transform.position;

        formationDir.Normalize();
        Vector3 newPosition = formationPos + formationDir * 0.1f;

        formCon.formation.PlanFormation(newPosition);

        foreach (Slot slot in formCon.slots)
        {
            if (slot.character == null)
            {
                continue;
            }

            GameObject slotCharacterAI = Utility.GetChildByTag(slot.character, Constants.AITag);
            slotCharacterAI.GetComponent <KinematicController>().SetTarget(slot.seekPosition);
        }
    }
예제 #5
0
 /// <summary>
 /// Call this method to initialize this enemy's data.
 /// </summary>
 /// <param name="path">Start paths</param>
 /// <param name="enemyFormation">Enemy main formation.</param>
 /// <param name="data">Current game data</param>
 /// <param name="enemyType">Enemy type</param>
 public override void Init(Path path, FormationController enemyFormation, GameData data, EnemyType enemyType)
 {
     base.Init(path, enemyFormation, data, enemyType);
     _Renderer.sprite = _StartForm;
     _isShooting      = false;
     _LaserController.Init(this, CharacterType.Enemy);
 }
 /// <summary>
 /// Call this method to set new path.
 /// </summary>
 /// <param name="caller">Registered formation</param>
 /// <param name="path">New path</param>
 public void UpdatePath(FormationController caller, Path path)
 {
     if (caller != _enemyFormation)
     {
         return;
     }
     _path = path;
 }
 /// <summary>
 /// Call this method to update enemy state.
 /// </summary>
 /// <param name="caller">Formation parent.</param>
 /// <param name="state">Enemy state.</param>
 public void UpdateState(FormationController caller, EnemyStates state)
 {
     if (caller != _enemyFormation)
     {
         return;
     }
     _enemyState = state;
 }
예제 #8
0
 public void TransferFormationTo(FormationController other)
 {
     for (int i = 0; i < slots.Length; i++)
     {
         other.slots[i].character    = slots[i].character;
         other.slots[i].seekPosition = slots[i].seekPosition;
     }
     other.formation.activeMembers = formation.activeMembers;
 }
예제 #9
0
        public IEnumerator Run(
            Client client,
            GameSession session,
            string formationNamespaceName,
            string moldModelName,
            GetMoldModelEvent onGetMoldModel,
            GetFormEvent onGetForm,
            UpdateFormEvent onUpdateForm,
            ErrorEvent onError
            )
        {
            if (_watching)
            {
                throw new InvalidOperationException("already started");
            }

            _watching = true;

            _client  = client;
            _session = session;
            _formationNamespaceName = formationNamespaceName;
            _moldModelName          = moldModelName;
            _onGetMoldModel         = onGetMoldModel;
            _onGetForm    = onGetForm;
            _onUpdateForm = onUpdateForm;
            _onError      = onError;

            void GetMoldModelAction(
                string formationNamespaceNameTmp,
                EzMoldModel moldModel
                )
            {
                if (formationNamespaceNameTmp != _formationNamespaceName)
                {
                    return;
                }

                _moldModel = moldModel;

                _onGetMoldModel.RemoveListener(GetMoldModelAction);
            }

            _onGetMoldModel.AddListener(GetMoldModelAction);

            yield return(FormationController.GetMoldModel(
                             _client,
                             formationNamespaceName,
                             moldModelName,
                             onGetMoldModel,
                             onError
                             ));

            _onGetForm.AddListener(GetFormAction);

            yield return(Refresh());
        }
예제 #10
0
    /// <summary>
    /// Call this routine method to spawn wave of enemies.
    /// </summary>
    /// <returns></returns>
    private IEnumerator SpawnWaves()
    {
        int currentWave = 0;

        while (currentWave < WaveList.Count)
        {
            for (int i = 0; i < WaveList[currentWave].FirstEnemyList.Count; i++)
            {
                Vector3             startPath   = WaveList[currentWave].FirstPath.BezierPathList[0];
                Path                currentPath = WaveList[currentWave].FirstPath;
                FormationController currentFormationController = GetFormation(WaveList[currentWave].FirstEnemyList[i]);

                GameObject newFly = GetCharacter(WaveList[currentWave].FirstEnemyList[i]);
                newFly.transform.SetParent(this.transform);
                newFly.transform.position = startPath;

                BaseEnemyController enemyController = newFly.GetComponent <BaseEnemyController>();

                enemyController.Init(currentPath
                                     , currentFormationController
                                     , _data
                                     , WaveList[currentWave].FirstEnemyList[i]
                                     );


                if (WaveList[currentWave].SecondEnemyList != null && WaveList[currentWave].SecondEnemyList.Count > 0)
                {
                    startPath   = WaveList[currentWave].SecondPath.BezierPathList[0];
                    currentPath = WaveList[currentWave].SecondPath;
                    currentFormationController = GetFormation(WaveList[currentWave].SecondEnemyList[i]);

                    newFly = GetCharacter(WaveList[currentWave].SecondEnemyList[i]);
                    newFly.transform.SetParent(this.transform);
                    newFly.transform.position = startPath;

                    enemyController = newFly.GetComponent <BaseEnemyController>();

                    enemyController.Init(currentPath
                                         , currentFormationController
                                         , _data
                                         , WaveList[currentWave].FirstEnemyList[i]
                                         );
                }

                yield return(new WaitForSeconds(EnemySpawnInterval));
            }

            yield return(new WaitForSeconds(WaveSpawnInterval));

            currentWave++;
        }

        _isAllSpawned = true;
        _isAttackAble = true;
    }
예제 #11
0
    IEnumerator Start()
    {
        analyticsManager = FindObjectOfType <AnalyticsManager>();
        bossFormation    = FindObjectOfType <FormationController>();
        cyclesCompleted  = 0;

        do
        {
            yield return(StartCoroutine(SpawnAllWaves()));
        }while (looping);
    }
예제 #12
0
    void Start()
    {
        if (!_formation)
        {
            _formation = FindObjectOfType <FormationController>();
        }

        Hp        *= Mathf.Pow(PerHpRaisedPerLvl, _formation.Lvl);
        MaxReload *= Mathf.Pow(PerMaxReloadReducedPerLvl, _formation.Lvl);
        MinReload *= Mathf.Pow(PerMinReloadReducedPerLvl, _formation.Lvl);
    }
예제 #13
0
        public IEnumerator Refresh()
        {
            yield return(FormationController.ListForms(
                             _client,
                             _session,
                             _formationNamespaceName,
                             _moldModel,
                             _onGetForm,
                             _onError
                             ));

            onDoneSetup.Invoke();
        }
    /// <summary>
    /// Call this method to initialize this enemy's data.
    /// </summary>
    /// <param name="path">Start paths</param>
    /// <param name="enemyFormation">Enemy main formation.</param>
    /// <param name="data">Current game data</param>
    /// <param name="enemyType">Enemy type</param>
    public virtual void Init(Path path, FormationController enemyFormation, GameData data, EnemyType enemyType)
    {
        _path           = path;
        _enemyID        = enemyFormation.GetNewEnemyID();
        _currentHealth  = _BaseHealth;
        _enemyFormation = enemyFormation;
        _enemyState     = EnemyStates.PathFollowing;
        _characterType  = CharacterType.Enemy;
        _enemyType      = enemyType;
        _speed          = data.Speed;

        _isInit = true;
        _isHit  = false;
    }
예제 #15
0
    void Awake()
    {
        teamMembers = new List <TeamController>();
        agentCon    = transform.parent.gameObject.GetComponent <AgentController>();
        Debug.Assert(agentCon != null);

        if (agentCon.gameObject.tag == Constants.MercenaryTag)
        {
            return;
        }

        GameObject formationObject = TD_Utility.Utility.GetChildByTag(gameObject, Constants.FormationTag);

        formCon = formationObject.GetComponent <FormationController>();
        Debug.Assert(formCon != null);
    }
    void Start()
    {
        formationController = GameObject.FindObjectOfType <FormationController> ();
        //enemyDownHandler = enemyFormation.OnEnemyDown;
        enemyDownHandler = formationController.OnEnemyDown;        //replaces standard delegate



        //if (rank == Rank.Leader) {

        Debug.Log("I am the leader");


        //}
//		if (rank != Rank.Leader) {
//			//add an offset to the target or make them imitate leader
//		}
    }
예제 #17
0
 // Use this for initialization
 void Start()
 {
     if (this.transform.parent.name == "myTroop_1")
     {
         anchor = Army_anchors.GetChild(0);
     }
     else if (this.transform.parent.name == "myTroop_2")
     {
         anchor = Army_anchors.GetChild(1);
     }
     else if (this.transform.parent.name == "myTroop_3")
     {
         anchor = Army_anchors.GetChild(2);
     }
     else if (this.transform.parent.name == "myTroop_4")
     {
         anchor = Army_anchors.GetChild(3);
     }
     else if (this.transform.parent.name == "myTroop_5")
     {
         anchor = Army_anchors.GetChild(4);
     }
     else if (this.transform.parent.name == "myTroop_6")
     {
         anchor = Army_anchors.GetChild(5);
     }
     else if (this.transform.parent.name == "myTroop_7")
     {
         anchor = Army_anchors.GetChild(6);
     }
     else if (this.transform.parent.name == "myTroop_8")
     {
         anchor = Army_anchors.GetChild(7);
     }
     zone_blue           = GameObject.Find("Zone_blue").transform;
     zone_red            = GameObject.Find("Zone_red").transform;
     formationController = anchor.GetComponent <FormationController>();
     agent         = this.GetComponent <NavMeshAgent>();
     index_troop   = this.transform.GetSiblingIndex();
     health        = 200;
     detect_radius = 20;
 }
예제 #18
0
    void OnLevelWasLoaded(int level)
    {
        if (SceneManager.GetActiveScene().name == "Level01")
        {
            Debug.Log("Onlvl vas load");
            currentLevel       = 1;
            instance.winCanvas = GameObject.Find("WinCanvas");
            instance.winCanvas.SetActive(false);
        }
        else if (SceneManager.GetActiveScene().name == "Level02")
        {
            currentLevel           = 2;
            instance.waveCanvas    = GameObject.Find("WaveCanvas");
            instance.waveCanvasTxt = GameObject.Find("WaveCountTxt").GetComponent <Text>();
            instance.waveCanvas.SetActive(false);
            zombieCount = 0;

            formationController = GameObject.Find("EnemySpawner").GetComponent <FormationController>();
            instance.StartCoroutine("StartNewWave");
        }
    }
예제 #19
0
    private void ReevaluateFormation(TeamController teamCon, GameObject agent)
    {
        GameObject          formationObject = TD_Utility.Utility.GetChildByTag(agent, Constants.FormationTag);
        FormationController formCon         = formationObject.GetComponent <FormationController>();

        if (formCon == null)
        {
            return;
        }

        bool hasFormation = false;

        foreach (TeamController member in teamCon.GetTeamMembers())
        {
            if (member.IsTeamLeader())
            {
                continue;
            }

            hasFormation = false;
            foreach (Slot slot in formCon.slots)
            {
                if (slot.character == null)
                {
                    continue;
                }
                if (slot.character.GetInstanceID() == member.transform.parent.gameObject.GetInstanceID())
                {
                    hasFormation = true;
                    break;
                }
            }

            if (hasFormation == false)
            {
                AddToFormation(formCon, member);
            }
        }
    }
예제 #20
0
    private void CreateFormation(GameObject agent, GameObject ai)
    {
        GameObject          formation = Utility.GetChildByTag(ai, Constants.FormationTag);
        FormationController formCon   = formation.GetComponent <FormationController>();
        TeamController      teamCon   = ai.GetComponent <TeamController>();

        foreach (TeamController ally in teamCon.GetTeamMembers())
        {
            formCon.AddFormationMember(ally.gameObject.transform.parent.gameObject);
        }

        AgentController agentCon     = agent.GetComponent <AgentController>();
        GameObject      nearestEnemy = GetNearestEnemy(agent, ai, agentCon);

        float distanceNearestEnemySqrd = (nearestEnemy.transform.position - agent.transform.position).sqrMagnitude;

        if (distanceNearestEnemySqrd > agentCon.attackRange * agentCon.attackRange)
        {
            Vector3 distToEnemy = nearestEnemy.transform.position - agent.transform.position;
            distToEnemy.y = 0;
            distToEnemy.Normalize();
            Vector3 formationCenter = nearestEnemy.transform.position - distToEnemy * agentCon.attackRange * 0.5f;
            formCon.formation.SetCurrentCenter(agent.transform.position);

            formCon.formation.PlanFormation(formationCenter);
            for (int i = 0; i < formCon.formation.maxCountMembers; i++)
            {
                if (formCon.slots[i].character == null)
                {
                    continue;
                }

                GameObject slotCharacterAI = Utility.GetChildByTag(formCon.slots[i].character, Constants.AITag);
                slotCharacterAI.GetComponent <KinematicController>().SetTarget(formCon.slots[i].seekPosition);
            }
        }
    }
예제 #21
0
 void Start()
 {
     scoreKeeper         = GameObject.Find("Score").GetComponent <ScoreKeeper>();
     formationcontroller = GameObject.FindObjectOfType <FormationController>();
 }
예제 #22
0
        private IEnumerator UpdateParty(
            int index,
            IEnumerable <EzSlot> units,
            string signatureKeyId
            )
        {
            var signedSlots = new List <EzSlotWithSignature>();

            foreach (var unit in units)
            {
                void OnGetItemSetWithSignature(
                    string itemSetId,
                    string signatureKeyIdTmp,
                    string body,
                    string signature
                    )
                {
                    if (itemSetId != unit.PropertyId || signatureKeyIdTmp != signatureKeyId)
                    {
                        return;
                    }

                    signedSlots.Add(
                        new EzSlotWithSignature
                    {
                        Name         = unit.Name,
                        PropertyType = "gs2_inventory",
                        Body         = body,
                        Signature    = signature,
                    }
                        );
                }

                if (unit.PropertyId != null)
                {
                    unitSetting.onGetItemSetWithSignature.AddListener(OnGetItemSetWithSignature);

                    yield return(InventoryController.GetItemSetWithSignature(
                                     _client,
                                     _session,
                                     unitSetting.inventoryNamespaceName,
                                     unitSetting.inventoryModelName,
                                     ItemSet.GetItemNameFromGrn(unit.PropertyId),
                                     ItemSet.GetItemSetNameFromGrn(unit.PropertyId),
                                     signatureKeyId,
                                     unitSetting.onGetItemSetWithSignature,
                                     _partySetting.onError
                                     ));

                    unitSetting.onGetItemSetWithSignature.RemoveListener(OnGetItemSetWithSignature);
                }
            }

            if (signedSlots.Count > 0)
            {
                yield return(FormationController.SetForm(
                                 _client,
                                 _session,
                                 _partySetting.formationNamespaceName,
                                 _formationWatcher.MoldModel,
                                 index,
                                 signedSlots,
                                 signatureKeyId,
                                 _partySetting.onGetForm,
                                 _partySetting.onUpdateForm,
                                 _partySetting.onError
                                 ));
            }
        }
예제 #23
0
 // Spawn a pack of wolves at the given location
 public void spawnWolfPack(Vector2 location)
 {
     FormationController formationController = Instantiate(FORMATION, location, Quaternion.identity);
 }
 void Start()
 {
     // find the formation controller
     _controller = transform.parent.gameObject.GetComponent<FormationController>();
 }
 void Start()
 {
     // find the formation controller
     _controller = transform.parent.gameObject.GetComponent <FormationController>();
 }
예제 #26
0
 // Use this for initialization
 void Start()
 {
     form = GameObject.FindObjectOfType <FormationController>();
 }
예제 #27
0
	void Connections() {
		if (!waveboard) { waveboard = GameObject.FindWithTag("Waveboard").GetComponent<Text>(); }
			if (!waveboard) Debug.LogError("Level Manager Connections !waveboard");
		if (!formation) formation = enemyFormation.GetComponent<FormationController>();
			if (!formation) Debug.Log ("Level Manager Connections !formation");
		if (!frameboard) frameboard = GameObject.FindWithTag("Frameboard").GetComponent<Text>();
			if (!frameboard) Debug.LogError("Level Manager Connections !frameboard");
		if (!scoreboard) scoreboard = GameObject.FindWithTag("Scoreboard").GetComponent<Text>();
			if (!scoreboard) Debug.LogError("Level Manager Connections !scoreboard");
	}