Beispiel #1
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag.Contains(mtag) && !other.tag.Contains("Base"))
        {
            if (CardName.Contains("LightningBolt") || CardName.Contains("BBQfor1"))
            {
                if (UnitList.Count < 1)
                {
                    UnitList.Add(other.gameObject);
                }
            }
            else
            {
                UnitList.Add(other.gameObject);

                if (CardName.Contains("Discharge"))
                {
                    if (this.transform.parent.GetComponent <NetworkIdentity>().isServer)
                    {
                        randomDischarge = data.getRandom(0f, 1f);
                    }
                    if (randomDischarge < perctChance)
                    {
                        workDischarge(other.gameObject, damage);
                    }
                }
                else if (CardName.Contains("ElectricArc"))
                {
                    workElectric(other.gameObject, true);
                }
            }
        }
    }
Beispiel #2
0
 void workElectric(GameObject _unit, bool add)
 {
     data.decreaseAttackSpeed(_unit, perctAttackSpeed, add);
     data.decreaseMoveSpeed(_unit, perctSpeed, add);
     if (!CardName.Contains("Avalanche"))
     {
         data.doDirectDamage(_unit, damage);
     }
 }
Beispiel #3
0
    void StaticbubbleCheck()
    {
        if (CardName.Contains("StaticBubble"))
        {
            interval = 1;

            if (!b_staticBubblePlayed && Time.time >= startTime + (time / 2))
            {
                damage = damage * 2;
                b_staticBubblePlayed = true;
            }
        }
    }
Beispiel #4
0
    void OnTriggerExit(Collider other)
    {
        if (UnitList.Contains(other.gameObject))
        {
            UnitList.Remove(other.gameObject);

            if (CardName.Contains("Discharge"))
            {
                workDischarge(other.gameObject, 0);
            }
            else if (CardName.Contains("ElectricArc"))
            {
                workElectric(other.gameObject, false);
            }
        }
    }
Beispiel #5
0
    // Use this for initialization
    void Start()
    {
        cardName             = this.transform.parent.gameObject.name.Substring(0, this.transform.parent.gameObject.name.Length - 7);
        data                 = new CardsBase(cardName);
        type                 = data.Type;
        category             = data.Category;
        damage               = data.Damage;
        radius               = data.Radius;
        time                 = data.Time;
        perctAttackSpeed     = data.PerctAttackSpeed;
        perctSpeed           = data.PerctSpeed;
        perctChance          = data.PerctChance;
        b_staticBubblePlayed = false;
        randomUnit           = 0;

        this.transform.parent.localScale = new Vector3(radius, radius, radius);

        startTime = Time.time;
        UnitList  = new List <GameObject>();


        if (this.transform.parent.GetComponent <NetPlayerCheck>().IsPlayer1)
        {
            mtag = "Player";
        }
        else
        {
            mtag = "Enemy";
        }


        //interval = time - 0.15f;
        if (cardName.Contains("SandStorm"))
        {
            interval = 1;
            time    += 0.5f;
        }
        else if (CardName.Contains("Avalanche"))
        {
            interval = 1;
        }
        else
        {
            interval = time / 1.5f;
        }
    }
Beispiel #6
0
    void LightningStormCheck()
    {
        if (CardName.Contains("LightningStorm"))
        {
            interval = 2;
            GameObject[] tempEnemies = GameObject.FindGameObjectsWithTag(mtag);

            UnitList.Clear();

            if (tempEnemies.Length > 0)
            {
                if (this.transform.parent.GetComponent <NetworkIdentity>().isServer)
                {
                    randomUnit = data.getRandom(0, tempEnemies.Length);
                }

                UnitList.Add(tempEnemies[randomUnit]);
            }
        }
    }
Beispiel #7
0
    // Update is called once per frame
    void Update()
    {
        if (!played)
        {
            if (CardName.Contains("ElectricArc") || CardName.Contains("Discharge"))
            {
                played = true;
            }
            else
            {
                StartCoroutine(Work());
                played = true;
            }
        }
        if (Time.time > startTime + time)
        {
            foreach (GameObject enemy in UnitList)
            {
                if (enemy != null)
                {
                    if (CardName.Contains("Discharge"))
                    {
                        workDischarge(enemy, 0);
                    }
                    else if (CardName.Contains("ElectricArc") || CardName.Contains("Avalanche"))
                    {
                        workElectric(enemy, false);
                    }
                }
            }

            if (UnitList != null)
            {
                UnitList.Clear();
            }

            Destroy(this.transform.parent.gameObject);
        }
    }
Beispiel #8
0
        private void LoadSelectedLesson()
        {
            CodeProfiler.Start("LoadLesson");
            Debug.WriteLine("Loading lesson: " + SelectedLesson);
            KillImageLoader();

            string lessonPath = LessonBasePath + SelectedLesson;

            string[] files = Directory.GetFiles(lessonPath);
            Array.Sort(files);

            //Clean up old cards. Dispose Audio object.
            foreach (FlashCardItem ptrItem in Cards)
            {
                ptrItem.Dispose();
            }
            Cards.Clear();
            FlashCardItem newItem;

            //Load and sort cards.
            CodeProfiler.Start("Generate Items");
            string CardName;
            string CardText;
            string CardImageType;

            foreach (string ptrFile in files)
            {
                //Card Format
                //[CardIndex]#<Card Name>.<Image type>
                CardImageType = Path.GetExtension(ptrFile).ToLower();
                if (!IsImageTypeSupported(CardImageType))
                {
                    continue;
                }

                CardName = CardText = Path.GetFileNameWithoutExtension(ptrFile);
                if (CardName.Contains("#"))
                {
                    CardText = CardName.Substring(CardName.IndexOf("#") + 1);
                }
                newItem = new FlashCardItem(CardName, CardText, ptrFile);
                Debug.WriteLine("> " + newItem.Text);
                Cards.Add(newItem);
            }
            CodeProfiler.Stop("Generate Items");

            //Load card contents.
            if (UseThread)
            {
                //Use threading to load images.
                CardsLoader = new Thread(LoadCardsData);
                CardsLoader.Start();
                CodeProfiler.Start("LoadCard1");
                Cards[0].Load(); //Make sure first image is loaded
                CodeProfiler.Stop("LoadCard1");
            }
            else
            {
                //Single thread operation (Slower) - Keep for debugging purpose
                foreach (FlashCardItem ptrItem in Cards)
                {
                    CodeProfiler.Start("Load Card " + ptrItem.Name);
                    ptrItem.Load();
                    CodeProfiler.Stop("Load Card " + ptrItem.Name);
                }
            }

            Cards.ResetIndex();
            CardsLoader.Join();
            OnLessonLoaded();
            Debug.WriteLine("Lesson loaded.");
            CodeProfiler.Stop("LoadLesson");
        }