Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        transform.SetParent(Dial.spawnLayer, false);
        RectTransform shieldRT = (RectTransform)parentShield.transform;
        RectTransform rt       = (RectTransform)transform;
        //find your angle
        float parentAngle = parentShield.gameObject.transform.eulerAngles.z;
        float angle       = (parentAngle + 90) % 360;

        angle *= (float)Math.PI / 180;
        //Debug.Log ("original angle: " + angle);
        angle = (angle - (float)Math.PI / 6f) + ((((float)Math.PI / 3f) / (2))); //handles spread effect
        //find where to spawn the wave
        gunDistFromCenter = (float)Math.Sqrt(shieldRT.anchoredPosition.x * shieldRT.anchoredPosition.x +
                                             shieldRT.anchoredPosition.y * shieldRT.anchoredPosition.y);
        gunDistFromCenter += 0.47f;
        spawnx             = gunDistFromCenter * (float)Math.Cos(angle);
        spawny             = gunDistFromCenter * (float)Math.Sin(angle);
        //Debug.Log (bc.speed);
        rt.anchoredPosition = new Vector2(spawnx, spawny);
        transform.rotation  = parentShield.gameObject.transform.rotation;
        vx = speed * (float)Math.Cos(angle);
        vy = speed * (float)Math.Sin(angle);

        originalScale = rt.localScale;

        dial = GameObject.Find("Dial").GetComponent <Dial>();

        if (PlayerPrefsInfo.Int2Bool(PlayerPrefs.GetInt(PlayerPrefsInfo.s_vampire)))
        {
            vampIsOn = true;
        }
    }
Esempio n. 2
0
    void Start()
    {
        healthBar = transform.Find("Health").gameObject;

        EventManager.Instance().RegisterForEventType("enemy_arrived", this);
        EventManager.Instance().RegisterForEventType("dial_damaged", this);
        EventManager.Instance().RegisterForEventType("health_leeched", this);
        LoadDialConfigFromJSON(WorldData.dialSelected);

        bonusWaveDictionary = new Dictionary <string, System.Object>();
        bonusWaveDictionary.Add("levelID", 0L);
        bonusWaveDictionary.Add("waveID", 404L);
        bonusWaveDictionary.Add("maxMilliseconds", (long)(bonusCapacity * 1000));
        bonusWaveDictionary.Add("minimumInterval", 1000L);
        bonusWaveDictionary.Add("enemies", new List <System.Object>());

        zoneLines    = GameObject.Find("ZoneLines").gameObject;
        superBars[0] = zoneLines.transform.Find("Super1").gameObject;
        superBars[1] = zoneLines.transform.Find("Super2").gameObject;
        superBars[2] = zoneLines.transform.Find("Super3").gameObject;
        for (int i = 0; i < 3; i++)
        {
            Transform bar = superBars[i].transform;
            bar.localScale = new Vector3(0.0f, bar.localScale.y, bar.localScale.z);
        }

        guns = GetAllGuns();

        if (PlayerPrefsInfo.Int2Bool(PlayerPrefs.GetInt(PlayerPrefsInfo.s_vampire)))
        {
            vampireIsOn = true;
        }
    }
Esempio n. 3
0
    //apply damage and effects to all enemies in This zone
    void Blast()
    {
        dial = GameObject.Find("Dial").GetComponent <Dial>();
        List <Enemy> enemyList = Dial.GetAllEnemiesInZone(zoneID);

        for (int i = 0; i < enemyList.Count; i++)
        {
            if (PlayerPrefsInfo.Int2Bool(PlayerPrefs.GetInt(PlayerPrefsInfo.s_vampire)))
            {
                float ehp = enemyList[i].GetHP();
                if (ehp < damage * vampDrain)
                {
                    dial.ChangeHealth(ehp);
                }
                else
                {
                    dial.ChangeHealth(damage * vampDrain);
                }
            }
            enemyList[i].TakeDamage(damage);
            if (parentShield != null && enemyList[i] != null)
            {
                enemyList[i].ShieldInflictedStatus(parentShield);
            }
        }
    }
Esempio n. 4
0
    // Use this for initialization
    void Start()
    {
        dialObj = GameObject.Find("Dial");
        dial    = dialObj.GetComponent <Dial>();

        canvas = GameObject.Find("Canvas").GetComponent <Canvas>();
        EventManager.Instance().RegisterForEventType("shot_fired", this);
        GameObject overlayObject = transform.Find("CooldownLayer").gameObject;

        cooldownImg               = overlayObject.GetComponent <Image>();
        cooldownImg.type          = Image.Type.Filled;
        cooldownImg.fillMethod    = Image.FillMethod.Radial360;
        cooldownImg.fillClockwise = false;
        cooldownImg.fillAmount    = 0f;
        cooltimer = new Timer();

        GameObject chargeObject = transform.Find("ChargeLayer").gameObject;

        chargeImg            = chargeObject.GetComponent <Image>();
        chargeImg.type       = Image.Type.Filled;
        chargeImg.fillMethod = Image.FillMethod.Vertical;
        chargeImg.fillAmount = 0f;

        laneList = new LinkedLaneList();
        laneList.SetUpList();

        //defaults

        /*towerType = "Shield";
         * shieldRange = 1f;
         * dmg = 10;
         * speed = defaultBulletSpeed;
         * range = defaultBulletRange;
         * shieldHP = 100;*/

        //split bullet limits
        if (split > 4)
        {
            split = 4;
        }
        if (split < 1)
        {
            split = 1;
        }

        //if useLock risk is on
        if (PlayerPrefsInfo.Int2Bool(PlayerPrefs.GetInt(PlayerPrefsInfo.s_useLock)))
        {
            useLockIsOn = true;
        }

        //if vampire risk is on
        if (PlayerPrefsInfo.Int2Bool(PlayerPrefs.GetInt(PlayerPrefsInfo.s_vampire)))
        {
            vampDrain = defaultVampDrain;
        }
    }
Esempio n. 5
0
    // Use this for initialization
    protected virtual void Start()
    {
        collide      = GetComponent <CircleCollider2D>();
        rt           = GetComponent <RectTransform>();
        rt.sizeDelta = new Vector2(0.0001f, 0.0001f);
        time         = new Timer();
        filter       = new ContactFilter2D();
        filter.NoFilter();
        dial = GameObject.Find("Dial").GetComponent <Dial>();

        if (PlayerPrefsInfo.Int2Bool(PlayerPrefs.GetInt(PlayerPrefsInfo.s_vampire)))
        {
            vampIsOn = true;
        }
    }
Esempio n. 6
0
    // Use this for initialization
    protected override void Start()
    {
        polyCollide = GetComponent <PolygonCollider2D>();
        rt          = GetComponent <RectTransform>();
        time        = new Timer();
        filter      = new ContactFilter2D();
        filter.NoFilter();
        dial  = GameObject.Find("Dial").GetComponent <Dial>();
        grown = true; //for now, doesn't grow

        if (PlayerPrefsInfo.Int2Bool(PlayerPrefs.GetInt(PlayerPrefsInfo.s_vampire)))
        {
            vampIsOn = true;
        }
    }
Esempio n. 7
0
    // Use this for initialization
    void Start()
    {
        rt           = GetComponent <RectTransform>();
        rt.sizeDelta = new Vector2(0.0001f, 0.0001f);
        collide      = GetComponent <CircleCollider2D>();
        time         = new Timer();

        if (PlayerPrefsInfo.Int2Bool(PlayerPrefs.GetInt(PlayerPrefsInfo.s_vampire)))
        {
            vampIsOn = true;
        }
        Debug.Log("created AoE, canDamageDial = " + canDamageDial);

        filter = new ContactFilter2D();
        filter.NoFilter();
    }
Esempio n. 8
0
    // Use this for initialization
    void Start()
    {
        //Debug.Log("Drop.cs called Start()");
        rt = GetComponent <RectTransform>();
        if (PlayerPrefsInfo.Int2Bool(PlayerPrefs.GetInt(PlayerPrefsInfo.s_sabotage)))
        {
            sabotageIsOn = true;
        }
        if (PlayerPrefsInfo.Int2Bool(PlayerPrefs.GetInt(PlayerPrefsInfo.s_tougherEnemies)))
        {
            tougherEnemiesIsOn = true;
            omniBoost          = PlayerPrefsInfo.GetOmnitechDropRateBoost(); //value between 0 and 1
        }

        omnitechTypes = new List <string> {
            "cooldown", "energyGain", "comboKey", "selfRepair"
        };
    }
Esempio n. 9
0
    public void StartMoving()
    {
        //Tougher Enemies risk
        if (PlayerPrefsInfo.Int2Bool(PlayerPrefs.GetInt(PlayerPrefsInfo.s_tougherEnemies)))
        {
            Debug.Log("calling applyriskstatchanges");
            ApplyRiskStatChanges();
        }
        //Debug.Log ("start moving called on " + this.ToString());
        ConfigureEnemy();
        steering       = gameObject.AddComponent <Steering>() as Steering;
        steering.enemy = this;
        float speedMult = 1f / (impactTime / NORMAL_IMPACT_TIME);

        steering.maxSpeed          = speedMult * NORMAL_SPEED;
        steering.referenceMaxSpeed = steering.maxSpeed;
        steering.maxAccel          = steering.maxSpeed / FRAMES_FROM_ZERO_TO_MAX;
        steering.referenceMaxAccel = steering.maxAccel;
        path = AIPath.CreatePathFromJSONFilename(moverType);
        path.SetDialDimensions(Dial.spawnLayer.anchoredPosition, Dial.FULL_LENGTH);
        path.SetAngle(GetStartingTrackAngle() + (-trackLane * 15f) + moverLaneOverride);
        steering.StartFollowingPath(path);
        steering.SpeedBoost((1f + riskSpeedBoost), 99999999f); //apply Tougher Enemies risk speed bonus

        /*List<Vector2> pathlist = path.GetPathAsListOfVectors();
         * foreach(Vector2 node in pathlist){ //path visualization
         *      GameObject dot = new GameObject();
         *      Image dimg = dot.AddComponent<Image>() as Image;
         *      dot.transform.SetParent(Dial.unmaskedLayer,false);
         *      dot.GetComponent<RectTransform>().sizeDelta = new Vector2(5f,5f);
         *      dot.GetComponent<RectTransform>().anchoredPosition = node;
         * }*/
        //some scaling- could maybe be done through transform.scale, but I don't trust Unity to handle the collider
        ScaleEnemy();
        spawned = true;
        moving  = true;

        //float angle = Mathf.Atan2(rt.anchoredPosition.y , rt.anchoredPosition.x);
        //ySpeed = Mathf.Sin (angle) * speed;
        //xSpeed = Mathf.Cos (angle) * speed;
    }
Esempio n. 10
0
    public void Start()
    {
        canvas = GameObject.Find("Canvas").GetComponent <Canvas>();
        RectTransform rt = (RectTransform)transform;
        EventManager  em = EventManager.Instance();

        em.RegisterForEventType("mouse_release", this);
        em.RegisterForEventType("mouse_click", this);
        anchorX = rt.anchoredPosition.x;
        anchorY = rt.anchoredPosition.y;

        for (int i = 1; i < 7; i++)
        {
            gunButtons[i - 1] = GameObject.Find("Button" + i).GetComponent <GunButton>();
        }

        SetDirectionMult(); //sets directionMult based on Risk "inverse dial" setting

        //Rotate-lock
        if (PlayerPrefsInfo.Int2Bool(PlayerPrefs.GetInt(PlayerPrefsInfo.s_rotLock)))
        {
            rotLockIsOn = true;
        }
    }