Exemple #1
0
    private void Start()
    {
        enemiesSummonPositions[0] = GameObject.FindGameObjectWithTag("Spawn1").transform;
        enemiesSummonPositions[1] = GameObject.FindGameObjectWithTag("Spawn2").transform;
        enemiesSummonPositions[2] = GameObject.FindGameObjectWithTag("Spawn3").transform;
        enemiesSummonPositions[3] = GameObject.FindGameObjectWithTag("Spawn4").transform;

        numOfWizardToSpawn = Mathf.Clamp(numOfWizardToSpawn, 1, enemiesSummonPositions.Length);

        if (king == null)
        {
            king = GameObject.FindGameObjectWithTag("KingPrefab");
        }
        lastShapeShiftTime = Time.time;
        shapeshifter       = GetComponent <Shapeshifter>();
        if (hasTransformed)
        {
            StartCoroutine(BackToNormaleShape());
        }
    }
    public void Transform(GameObject toCopy, bool isItPlayer)//if it's not a player the it's a king
    {
        GameObject newForm = Instantiate(toCopy, transform.position, transform.rotation);

        newForm.AddComponent <Shapeshifter>();
        Shapeshifter shift = newForm.GetComponent <Shapeshifter>();

        shift.icon         = icon;
        shift.abilityName  = abilityName;
        shift.cooldownTime = cooldownTime;
        shift.speedBonus   = speedBonus;
        shift.projectileCooldownMultiplier = projectileCooldownMultiplier;
        shift.lifeBonus   = lifeBonus;
        shift.justShifted = true;



        if (isItPlayer)
        {
            var health = newForm.GetComponent <Damagable>();
            health.MaximumLife += lifeBonus;
            health.CurrentLife  = health.MaximumLife;

            Destroy(newForm.GetComponent <EnemyAI>());
            Destroy(newForm.GetComponent <DestroyOnDeath>());


            newForm.AddComponent <CameraCenter>();
            newForm.AddComponent <ChangeSceneOnDeath>();
            newForm.AddComponent <PlayerController>();
            newForm.GetComponent <Mover>().initialSpeed += speedBonus;
            newForm.GetComponent <ProjectileLauncher>().timeBetweenShots *= projectileCooldownMultiplier;
            newForm.gameObject.name = "Player";
            newForm.gameObject.tag  = "Player";
        }
        else
        {
            newForm.layer           = 0;//give him the layer default (to not give him the layer enemy and by that we prevent the player from shapeshift to it even wehn he is a wizard)
            newForm.gameObject.name = "King";

            switch (shapeshiftType)
            {
            case earthShifshape: newForm.AddComponent <BoulderAbility>(); break;

            case fireShifshape: newForm.AddComponent <Flamethrower>(); break;

            case waterShifshape: newForm.AddComponent <HealAbility>(); break;

            case windShifshape: newForm.AddComponent <WindShieldAbility>(); break;

            default:
                break;
            }

            KingAbility newKingAbility = newForm.AddComponent <KingAbility>();
            newKingAbility.wizards = kingAbility.wizards;
            newKingAbility.enemiesSummonPositions = kingAbility.enemiesSummonPositions;
            newKingAbility.secToShapeshitf        = kingAbility.secToShapeshitf;
            newKingAbility.secToShapeshitf        = kingAbility.secToBackToNormaleShape;
            newKingAbility.king = kingAbility.king;
        }


        Destroy(gameObject);
    }
Exemple #3
0
 public void AttachTo(Shapeshifter shapeshift, Ability ability, Damagable health)
 {
     shapeshiftMeter.Ability = shapeshift;
     abilityMeter.Ability    = ability;
     damageMeter.ConnectDamagable(health);
 }