public void Activate(PlaceableData pData)
        {
            timeToRemoval = pData.lifeTime;
            dieAudioClip  = pData.dieClip;
            //TODO: add more as necessary

            StartCoroutine(Die());
        }
Beispiel #2
0
        public void Activate(Faction pFaction, PlaceableData pData)
        {
            pType      = pData.pType;
            faction    = pFaction;
            hitPoints  = pData.hitPoints;
            targetType = pData.targetType;

            constructionTimeline.Play();
        }
Beispiel #3
0
        public void Activate(Faction pFaction, PlaceableData pData)
        {
            pType           = pData.pType;
            faction         = pFaction;
            hitPoints       = pData.hitPoints;
            targetType      = pData.targetType;
            attackAudioClip = pData.attackClip;
            dieAudioClip    = pData.dieClip;
            //TODO: add more as necessary

            constructionTimeline.Play();
        }
        //setups all scripts and listeners on a Placeable GameObject
        private void SetupPlaceable(GameObject go, PlaceableData pDataRef, Placeable.Faction pFaction)
        {
            //Add the appropriate script
            switch (pDataRef.pType)
            {
            case Placeable.PlaceableType.Unit:
                Unit uScript = go.GetComponent <Unit>();
                uScript.Activate(pFaction, pDataRef);         //enables NavMeshAgent
                uScript.OnDealDamage      += OnPlaceableDealtDamage;
                uScript.OnProjectileFired += OnProjectileFired;
                AddPlaceableToList(uScript);         //add the Unit to the appropriate list
                UIManager.AddHealthUI(uScript);
                break;

            case Placeable.PlaceableType.Building:
            case Placeable.PlaceableType.Castle:
                Building bScript = go.GetComponent <Building>();
                bScript.Activate(pFaction, pDataRef);
                bScript.OnDealDamage      += OnPlaceableDealtDamage;
                bScript.OnProjectileFired += OnProjectileFired;
                AddPlaceableToList(bScript);         //add the Building to the appropriate list
                UIManager.AddHealthUI(bScript);

                //special case for castles
                if (pDataRef.pType == Placeable.PlaceableType.Castle)
                {
                    bScript.OnDie += OnCastleDead;
                }

                navMesh.BuildNavMesh();         //rebake the Navmesh
                break;

            case Placeable.PlaceableType.Obstacle:
                Obstacle oScript = go.GetComponent <Obstacle>();
                oScript.Activate(pDataRef);
                navMesh.BuildNavMesh();         //rebake the Navmesh
                break;

            case Placeable.PlaceableType.Spell:
                //Spell sScript = newPlaceable.AddComponent<Spell>();
                //sScript.Activate(pFaction, cardData.hitPoints);
                //TODO: activate the spell and… ?
                break;
            }

            go.GetComponent <Placeable>().OnDie += OnPlaceableDead;
        }
        //called by GameManager when this Unit is played on the play field
        public void Activate(Faction pFaction, PlaceableData pData)
        {
            faction     = pFaction;
            hitPoints   = pData.hitPoints;
            targetType  = pData.targetType;
            attackRange = pData.attackRange;
            attackRatio = pData.attackRatio;
            speed       = pData.speed;
            damage      = pData.damagePerAttack;
            //TODO: add more as necessary

            navMeshAgent.speed = speed;
            animator.SetFloat("MoveSpeed", speed); //will act as multiplier to the speed of the run animation clip

            state = States.Idle;
            navMeshAgent.enabled = true;
        }
Beispiel #6
0
        public void UseCard(CardData cardData, Vector3 position, Placeable.Faction pFaction)
        {
            for (int pNum = 0; pNum < cardData.placeablesData.Length; pNum++)
            {
                PlaceableData pDataRef = cardData.placeablesData[pNum];
                Quaternion    rot      = (pFaction == Placeable.Faction.Player) ? Quaternion.identity : Quaternion.Euler(0f, 180f, 0f);
                //Prefab to spawn is the associatedPrefab if it's the Player faction, otherwise it's alternatePrefab. But if alternatePrefab is null, then first one is taken
                GameObject prefabToSpawn  = (pFaction == Placeable.Faction.Player) ? pDataRef.associatedPrefab : ((pDataRef.alternatePrefab == null) ? pDataRef.associatedPrefab : pDataRef.alternatePrefab);
                GameObject newPlaceableGO = Instantiate <GameObject>(prefabToSpawn, position + cardData.relativeOffsets[pNum], rot);

                SetupPlaceable(newPlaceableGO, pDataRef, pFaction);

                appearEffectPool.UseParticles(position + cardData.relativeOffsets[pNum]);
            }

            updateAllPlaceables = true; //will force all AIBrains to update next time the Update loop is run
        }
Beispiel #7
0
        public void Activate(PlaceableData pData)
        {
            timeToRemoval = pData.lifeTime;

            StartCoroutine(Die());
        }