Inheritance: StaminaController
Esempio n. 1
0
 private void OnTriggerEnter(Collider collision)
 {
     invisible = collision.gameObject.GetComponent <Invisible>();
     invisiblethroughCoroutine = collision.gameObject.GetComponent <InvisiblethroughCoroutine>();
     invisible.Reappear();
     invisiblethroughCoroutine.Reappear();
 }
Esempio n. 2
0
        public Cloaking_Permanent(string name, string symbol)
            : base(name, symbol)
        {
            Effect = new Invisible();

            // TODO: work out how to actually apply this effect to units
        }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        atai_sum1 = BraveSmash.Atai2();
        atai_sum2 = AeroLast.Atai2();
        atai_sum3 = Boneboomerang.Atai2();
        atai_sum4 = Superspeedplayback.Atai2();
        atai_sum5 = Barrier.Atai2();
        atai_sum6 = Superhumanization.Atai2();
        atai_sum7 = Invisible.Atai2();
        atai_sum8 = Revenge.Atai2();

        /*
         * Debug.Log(atai_sum1);
         * Debug.Log(atai_sum2);
         * Debug.Log(atai_sum3);
         * Debug.Log(atai_sum4);
         * Debug.Log(atai_sum5);
         * Debug.Log(atai_sum6);
         * Debug.Log(atai_sum7);
         * Debug.Log(atai_sum8);
         */
        atai_num = atai_sum1 + atai_sum2 + atai_sum3 + atai_sum4 + atai_sum5 + atai_sum6 + atai_sum7 + atai_sum8;
        //オブジェクトからTextコンポーネントを取得
        //Text atai_text = atai_object.GetComponent<Text>();
        //テキストの表示を入れ替える
        if (atai_num >= 0)
        {
            atai_text.text = atai_num + " / " + coin_num + "枚";
        }
    }
Esempio n. 4
0
        public void Apply_NotACharacter_Test()
        {
            var entity    = Mock.Of <IEntity>();
            var invisible = new Invisible();

            invisible.Apply(entity);
            Assert.IsTrue(true); // If we made it here without exception then the test passed
        }
Esempio n. 5
0
        public void Apply_Character_WithExistingInvisibleCondition_Test()
        {
            var character = CreateMockCharacter();

            character.Conditions.Add(new Invisible());
            var invisible = new Invisible();

            invisible.Apply(character);
        }
Esempio n. 6
0
        public void Remove_NoConditions_Test()
        {
            var character = CreateMockCharacter();
            var invisible = new Invisible();

            invisible.Apply(character);
            invisible.Remove(character);
            Assert.AreEqual(0, character.Conditions.Count);
        }
Esempio n. 7
0
        public void Apply_Character_NoConditions_Test()
        {
            var character = CreateMockCharacter();
            var invisible = new Invisible();

            invisible.Apply(character);
            Assert.AreEqual(EntityIds.INVISIBLE_CONDITION_ID, character.Conditions[0].Id);
            Assert.AreSame(invisible, character.Conditions[0]);
            Assert.AreEqual(ConditionGroup.Senses, character.Conditions[0].Group);
        }
Esempio n. 8
0
    void OnTriggerEnter(Collider other)
    {
        Invisible invisible = other.gameObject.GetComponent <Invisible>();

        if (other.CompareTag(Tags.player) && !invisible.IsInvisible())
        {
            camera.alarm_system.SetAlarm(ALARM_STATE.ALARM_ON);
            camera.last_spotted_position.LastPosition = other.transform.position;
            camera.ChangeStateTo(camera.following_state);
        }
    }
 public void Execute()
 {
     foreach (IBlock block in myGame.blockList)
     {
         if (block is Invisible)
         {
             Invisible invisible = block as Invisible;
             if (!invisible.used)
             {
                 invisible.BumpUp();
                 invisible.ChangeToUsed();
             }
         }
     }
 }
Esempio n. 10
0
        private static Invisible ParseInvisibleCombatData(XElement element)
        {
            Invisible invisible = new Invisible();

            if (element.Attribute("chance") is XAttribute chanceAttribute)
            {
                invisible.Chance = new Percent(byte.Parse(chanceAttribute.Value));
            }

            if (element.Attribute("duration") is XAttribute durationAttribute)
            {
                invisible.Duration = TimeSpan.FromMilliseconds(long.Parse(durationAttribute.Value));
            }

            return(invisible);
        }
        public bool Equals(DestinyMetricComponent input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     Invisible == input.Invisible ||
                     (Invisible != null && Invisible.Equals(input.Invisible))
                     ) &&
                 (
                     ObjectiveProgress == input.ObjectiveProgress ||
                     (ObjectiveProgress != null && ObjectiveProgress.Equals(input.ObjectiveProgress))
                 ));
        }
Esempio n. 12
0
    void Start()
    {
        controller = GetComponent <PlayerController> ();

        if (GameManager.maxLevelReached > 0)
        {
            abilities |= Ability.DESOLIDIFY;
        }
        if (GameManager.maxLevelReached > 1)
        {
            abilities |= Ability.POSSESS;
        }
        if (GameManager.maxLevelReached > 2)
        {
            abilities |= Ability.INVISIBILITY;
        }
        if (GameManager.maxLevelReached > 3)
        {
            abilities |= Ability.BLAST;
        }
        if (GameManager.maxLevelReached > 4)
        {
            abilities |= Ability.FOCUSED_BLAST;
        }

        if ((abilities & Ability.DESOLIDIFY) != 0)
        {
            gameObject.layer = 9;
        }
        else
        {
            gameObject.layer = 12;
        }

        hold         = GetComponent <Hold> ();
        possess      = GetComponent <Possess> ();
        invisible    = GetComponent <Invisible> ();
        blast        = GetComponent <Blast> ();
        focusedBlast = GetComponent <FocusedBlast> ();

        hold.pc         = controller;
        possess.pc      = controller;
        invisible.pc    = controller;
        blast.pc        = controller;
        focusedBlast.pc = controller;
    }
Esempio n. 13
0
 public WarperSpaceship()
 {
     SpaceshipClassName        = "Warper";
     SpaceshipClassDescription = "BALLANCED";
     Base_attack   = 15;
     Base_def      = 4;
     MaxHealth     = 1000;
     CurrentHealth = MaxHealth;
     QSkill        = new BasicAttack();
     WSkill        = new SteeringMissile();
     ESkill        = new BlasterOrb();
     ASkill        = new OrionMove();
     SSkill        = new Teleporter();
     DSkill        = new CircleMove();
     ZSkill        = new Invisible();
     XSkill        = new ElectricCharge();
     CSkill        = new BlackHole();
 }
Esempio n. 14
0
        private void Start()
        {
            // get the components on the object we need ( should not be null due to require component so no need to check )
            agent  = GetComponentInChildren <UnityEngine.AI.NavMeshAgent>();
            target = GameObject.FindGameObjectWithTag("Player").transform;

            agent.updateRotation = false;
            agent.updatePosition = true;

            invisible = target.gameObject.GetComponent <Invisible>();

            animator = GetComponent <Animator>();
            animator.SetFloat("Move", 0.1f);
            agent.speed = wanderSpeed;

            pickup    = Resources.Load <GameObject>("Prefab_Pickup");
            particleR = Resources.Load <GameObject>("Prefab_EnemyParticle");
        }
Esempio n. 15
0
        public string[] ToArray()
        {
            string[] array = new string[16];

            array[0]  = Blinded.Equals("Cured") ? "" : "Blinded";
            array[1]  = Charmed.Equals("Cured") ? "" : "Charmed";
            array[2]  = Deafened.Equals("Cured") ? "" : "Deafened";
            array[3]  = Encumbrance.Equals("Normal") ? "" : Encumbrance;
            array[4]  = Fatigued.Equals("Cured") ? "" : Fatigued;
            array[5]  = Frightened.Equals("Cured") ? "" : "Frightened";
            array[6]  = Grappled.Equals("Cured") ? "" : "Grappled";
            array[7]  = Incapacitated.Equals("Cured") ? "" : "Incapacitated";
            array[8]  = Invisible.Equals("Cured") ? "" : "Invisible";
            array[9]  = Paralyzed.Equals("Cured") ? "" : "Paralyzed";
            array[10] = Petrified.Equals("Cured") ? "" : "Petrified";
            array[11] = Poisoned.Equals("Cured") ? "" : "Poisoned";
            array[12] = Prone.Equals("Cured") ? "" : "Prone";
            array[13] = Restrained.Equals("Cured") ? "" : "Restrained";
            array[14] = Stunned.Equals("Cured") ? "" : "Stunned";
            array[15] = Unconscious.Equals("Cured") ? "" : "Unconscious";

            return(array);
        }
        public static void InfiniteLevelLoad(Game myGame)
        {
            enemyList = new List <IEnemy>();
            itemList  = new List <IItem>();
            blockList = new List <IBlock>();
            bgList    = new List <IBg>();

            String[] levelFile = new String[two] {
                "InfiniteLevel-1.txt", "InfiniteLevel-2.txt"
            };
            int file = 0;

            StreamReader File = new StreamReader(Path.Combine(Directory.GetCurrentDirectory(),
                                                              "Content", "Levels", levelFile[file]));

            String inComingLine;
            int    posRow = zero;

            while (!File.EndOfStream)
            {
                inComingLine = File.ReadLine();
                String[] target = inComingLine.Split(',');
                int      posCol = zero;
                while (posCol < target.Length)
                {
                    if (target[posCol].Equals("brick"))
                    {
                        IBlock block = new Brick(myGame, posCol, posRow);
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("crack"))
                    {
                        IBlock block = new Crack(myGame, posCol, posRow);
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("diamond"))
                    {
                        IBlock block = new Diamond(myGame, posCol * stdSpriteSize, posRow * stdSpriteSize);
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("question"))
                    {
                        IBlock block = new Question(myGame, posCol, posRow);
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("questionRedM"))
                    {
                        Question block = new Question(myGame, posCol, posRow);
                        block.contain = Utility.items.redM;
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("questionFireF"))
                    {
                        Question block = new Question(myGame, posCol, posRow);
                        block.contain = Utility.items.flower;
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("questionCoin"))
                    {
                        Question block = new Question(myGame, posCol, posRow);
                        block.contain = Utility.items.coin;
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("questionGreenM"))
                    {
                        Question block = new Question(myGame, posCol, posRow);
                        block.contain = Utility.items.greenM;
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("questionBat"))
                    {
                        Question block = new Question(myGame, posCol, posRow);
                        block.contain = Utility.items.bat;
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("used"))
                    {
                        IBlock block = new Used(myGame, posCol, posRow);
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("invisible"))
                    {
                        IBlock block = new Invisible(myGame, posCol, posRow);
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("standardPipe"))
                    {
                        Pipe block = new Pipe(myGame, posCol, posRow);
                        blockList.Add(block);

                        IEnemy enemy = new PiranhaPlant(myGame, block.drawLoc.X, block.drawLoc.Y);
                        enemyList.Add(enemy);
                    }

                    else if (target[posCol].Equals("pipeNeck"))
                    {
                        IBlock block = new PipeNeck(myGame, posCol, posRow);
                        blockList.Add(block);
                    }

                    else if (target[posCol].Equals("coin"))
                    {
                        IItem item = new Coin(myGame, posCol * stdSpriteSize, posRow * stdSpriteSize);
                        itemList.Add(item);
                    }
                    else if (target[posCol].Equals("star"))
                    {
                        IItem item = new Star(myGame, posCol * stdSpriteSize, posRow * stdSpriteSize);
                        itemList.Add(item);
                    }
                    else if (target[posCol].Equals("flower"))
                    {
                        IItem item = new FireFlower(myGame, posCol * stdSpriteSize, posRow * stdSpriteSize);
                        itemList.Add(item);
                    }
                    else if (target[posCol].Equals("redMushroom"))
                    {
                        IItem item = new RedMushroom(myGame, posCol * stdSpriteSize, posRow * stdSpriteSize);
                        itemList.Add(item);
                    }
                    else if (target[posCol].Equals("greenMushroom"))
                    {
                        IItem item = new GreenMushroom(myGame, posCol * stdSpriteSize, posRow * stdSpriteSize);
                        itemList.Add(item);
                    }


                    else if (target[posCol].Equals("goomba"))
                    {
                        IEnemy enemy = new Goomba(myGame, posCol, posRow);
                        enemyList.Add(enemy);
                    }
                    else if (target[posCol].Equals("koopa"))
                    {
                        IEnemy enemy = new Koopa(myGame, posCol, posRow);
                        enemyList.Add(enemy);
                    }


                    else if (target[posCol].Equals("oneCloud"))
                    {
                        IBg bg = new Bg(myGame, myGame.oneCloudBgElement, posCol, posRow);
                        bgList.Add(bg);
                    }
                    else if (target[posCol].Equals("threeClouds"))
                    {
                        IBg bg = new Bg(myGame, myGame.threeCloudsBgElement, posCol, posRow);
                        bgList.Add(bg);
                    }
                    else if (target[posCol].Equals("oneBush"))
                    {
                        IBg bg = new Bg(myGame, myGame.oneBushBgElement, posCol, posRow);
                        bgList.Add(bg);
                    }
                    else if (target[posCol].Equals("threeBushes"))
                    {
                        IBg bg = new Bg(myGame, myGame.threeBushesBgElement, posCol, posRow);
                        bgList.Add(bg);
                    }
                    else if (target[posCol].Equals("smallMountain"))
                    {
                        IBg bg = new Bg(myGame, myGame.smallMountainBgElement, posCol, posRow);
                        bgList.Add(bg);
                    }
                    else if (target[posCol].Equals("bigMountain"))
                    {
                        IBg bg = new Bg(myGame, myGame.bigMountainBgElement, posCol, posRow);
                        bgList.Add(bg);
                    }
                    posCol++;
                }
                posRow++;
            }
            File.Close();
            if (file < two)
            {
                File = new StreamReader(Path.Combine(Directory.GetCurrentDirectory(),
                                                     "Content", "Levels", levelFile[file]));
                file++;
            }
            else
            {
                file = zero;
            }

            IComparer <IBlock> blockComp = new BlockComparer <IBlock>();
            IComparer <IItem>  itemComp  = new ItemComparer <IItem>();
            IComparer <IEnemy> enemyComp = new EnemyComparer <IEnemy>();

            blockList.Sort(blockComp);
            itemList.Sort(itemComp);
            enemyList.Sort(enemyComp);
        }
Esempio n. 17
0
    private IEnumerator addComponentByName(GameObject go, GameObject staticGO, string name, string data1, string data2, string data3, string data4, string data5)
    {
        go.layer       = LayerMask.NameToLayer("BlockingLayer");
        staticGO.layer = LayerMask.NameToLayer("BlockingLayer");
        switch (name)
        {
        case "PathFollowing":
            go.AddComponent <PathFollowing>().initDrawing(0, true).setStateToIdle();
            staticGO.AddComponent <PathFollowing>().initDrawing(0, false).setStateToIdle();
            break;

        case "SpriteRenderer":
        {
            SpriteRenderer r  = go.AddComponent <SpriteRenderer>();
            SpriteRenderer sr = staticGO.AddComponent <SpriteRenderer>();
            if (data1.Length > 0)
            {
                int index = data1.LastIndexOf('_');
                if (index > 0)
                {
                    int spriteIndex;
                    if (Int32.TryParse(data1.Substring(index + 1), out spriteIndex))
                    {
                        string   path    = data1.Substring(0, index);
                        Sprite[] sprites = Resources.LoadAll <Sprite>(path);
                        if (spriteIndex < sprites.Length)
                        {
                            r.sprite  = sprites[spriteIndex];
                            sr.sprite = sprites[spriteIndex];
                        }
                    }
                }
                else
                {
                    r.sprite  = Resources.Load <Sprite>(data1);
                    sr.sprite = Resources.Load <Sprite>(data1);
                }
            }
            if (data2.Length > 0)
            {
                r.sortingLayerName  = data2;
                sr.sortingLayerName = data2;
            }
        }
        break;

        case "Animator":
            go.AddComponent <Animator>().runtimeAnimatorController       = Resources.Load <RuntimeAnimatorController>(data1);
            staticGO.AddComponent <Animator>().runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>(data1);
            break;

        case "BoxCollider2D":
        {
            BoxCollider2D bc  = go.AddComponent <BoxCollider2D>();
            BoxCollider2D sbc = staticGO.AddComponent <BoxCollider2D>();
            bool          trigger;
            if (Boolean.TryParse(data1, out trigger))
            {
                bc.isTrigger  = trigger;
                sbc.isTrigger = trigger;
            }
        }
        break;

        case "RigidBody2D":
        {
            Rigidbody2D rb = go.AddComponent <Rigidbody2D>();
            bool        kinematic, fixedAngle;
            if (Boolean.TryParse(data1, out kinematic))
            {
                rb.isKinematic = kinematic;
            }
            if (Boolean.TryParse(data2, out fixedAngle))
            {
                rb.fixedAngle = fixedAngle;
            }
        }
        break;

        case "Tag":
            go.tag = data1;
            if (data1 == "PaintableBackground")
            {
                staticGO.tag = data1;
            }
            break;

        case "CustomScript":
            go.AddComponent(Type.GetType(data1));
            break;

        case "Move":
        {
            Move mc = go.AddComponent <Move>();
            mc.maxSpeed[0] = float.Parse(data1);
            mc.maxSpeed[1] = float.Parse(data2);
            mc.maxSpeed[2] = float.Parse(data3);
            mc.maxSpeed[3] = float.Parse(data4);
        }
        break;

        case "Jump":
        {
            go.AddComponent <Jump>();

            Rigidbody2D rb = null;
            rb = go.GetComponent <Rigidbody2D>();

            if (rb == null)
            {
                rb = go.AddComponent <Rigidbody2D>();
            }

            rb.isKinematic = false;
            rb.fixedAngle  = true;
        }
        break;

        case "Health":
        {
            BoxCollider2D c = null;
            c = go.GetComponent <BoxCollider2D>();

            if (c == null)
            {
                c = go.AddComponent <BoxCollider2D>();
            }

            Health h = go.AddComponent <Health>();
            Int32.TryParse(data1, out h.maxHP);
            Int32.TryParse(data2, out h.startHP);
            Int32.TryParse(data3, out h.directions);
            int deathAction;
            if (Int32.TryParse(data4, out deathAction))
            {
                h.setDeathAction(deathAction);
            }
            float.TryParse(data5, out h.damageCooldown);
        }
        break;

        case "Resize":
        {
            Resize r = staticGO.AddComponent <Resize>();
            r.arrowPrefab = pentaArrow;
            r.nonStatic   = go;
        }
        break;

        case "CollideTrigger":
        {
            CollideTrigger ct = go.GetComponent <CollideTrigger>();
            if (ct == null)
            {
                ct = go.AddComponent <CollideTrigger>();
            }
            CustomAction.ActionTypes a = (CustomAction.ActionTypes)Enum.Parse(typeof(CustomAction.ActionTypes), data1);
            int directions;
            Int32.TryParse(data2, out directions);

            string[]      delimiters = { "|" };
            string[]      tags = data3.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
            List <String> includedTags = new List <String>(), excludedTags = new List <String>();
            for (int i = 0; i < tags.Length; i++)
            {
                if (tags[i].StartsWith("!"))
                {
                    string tag = tags[i].Substring(1);
                    excludedTags.Add(tag);
                }
                else
                {
                    includedTags.Add(tags[i]);
                }
            }

            switch (a)
            {
            case CustomAction.ActionTypes.Spawn:
            {
                Spawn  s       = go.AddComponent <Spawn>();
                string rfidKey = data4;

                if (database.ContainsKey(rfidKey))
                {
                    s.toSpawn = database[rfidKey].first;
                }
                else
                {
                    string url = "http://" + databaseAddress + "/playtime/getComponents.php";
                    yield return(StartCoroutine(pollDatabase(url, rfidKey, false)));

                    if (database.ContainsKey(rfidKey))
                    {
                        s.toSpawn = database[rfidKey].first;
                    }
                }

                int spawnCount = 0;
                Int32.TryParse(data5, out spawnCount);
                s.setMaxSpawnCount(spawnCount);
                s.includedTags = includedTags;
                s.excludedTags = excludedTags;
                ct.actions.Add(s);
                ct.directions.Add(directions);
            }
            break;

            case CustomAction.ActionTypes.Despawn:
            {
                Despawn d = go.AddComponent <Despawn>();
                int     deathAnimID;
                int.TryParse(data4, out deathAnimID);
                d.deathAnimID        = deathAnimID;
                d.defaultDeathAnimID = deathAnimID;
                d.includedTags       = includedTags;
                d.excludedTags       = excludedTags;
                ct.actions.Add(d);
                ct.directions.Add(directions);
            }
            break;

            case CustomAction.ActionTypes.Transfigure:
            {
                Transfigure t = go.GetComponent <Transfigure>();
                if (t == null)
                {
                    t = go.AddComponent <Transfigure>();
                }
                bool repeatable;
                Boolean.TryParse(data5, out repeatable);
                t.addTargetAnimControllerAndTags(data4, includedTags, excludedTags, repeatable, ct.actions.Count);
                ct.actions.Add(t);
                ct.directions.Add(directions);
            }
            break;

            case CustomAction.ActionTypes.DespawnOther:
            {
                DespawnOther dOther = go.AddComponent <DespawnOther>();
                dOther.includedTags = includedTags;
                dOther.excludedTags = excludedTags;
                ct.actions.Add(dOther);
                ct.directions.Add(directions);
            }
            break;

            case CustomAction.ActionTypes.RespawnOther:
            {
                RespawnOther rOther = go.AddComponent <RespawnOther>();
                rOther.includedTags = includedTags;
                rOther.excludedTags = excludedTags;
                ct.actions.Add(rOther);
                ct.directions.Add(directions);
            }
            break;

            case CustomAction.ActionTypes.Damage:
            {
                Damage d = go.AddComponent <Damage>();
                d.includedTags = includedTags;
                d.excludedTags = excludedTags;
                Int32.TryParse(data4, out d.dmg);
                ct.actions.Add(d);
                ct.directions.Add(directions);
            }
            break;

            case CustomAction.ActionTypes.MoveHoriz:
            {
                MoveHorizontalUntilCollision m = go.AddComponent <MoveHorizontalUntilCollision>();
                m.includedTags = includedTags;
                m.excludedTags = excludedTags;
                float.TryParse(data4, out m.speed);
                m.tagsToIgnore = new List <string>(data5.Split(delimiters, StringSplitOptions.RemoveEmptyEntries));
                ct.actions.Add(m);
                ct.directions.Add(directions);
            }
            break;

            case CustomAction.ActionTypes.CustomScript:
            {
                Type         t    = Type.GetType(data4);
                Component    comp = go.AddComponent(t);
                CustomAction c    = (CustomAction)comp;
                c.includedTags = includedTags;
                c.excludedTags = excludedTags;
                ct.actions.Add(c);
                ct.directions.Add(directions);
            }
            break;

            case CustomAction.ActionTypes.Bounce:
            {
                Bounce b = go.AddComponent <Bounce>();
                b.includedTags = includedTags;
                b.excludedTags = excludedTags;
                float bounceHeight;
                float.TryParse(data4, out bounceHeight);
                b.bounceHeight = bounceHeight;
                ct.actions.Add(b);
                ct.directions.Add(directions);
            }
            break;

            default:
                break;
            }
        }
        break;

        case "TimeTrigger":
        {
            TimeTrigger tt = go.GetComponent <TimeTrigger>();
            if (tt == null)
            {
                tt = go.AddComponent <TimeTrigger>();
            }
            CustomAction.ActionTypes a = (CustomAction.ActionTypes)Enum.Parse(typeof(CustomAction.ActionTypes), data1);
            float time;
            float.TryParse(data2, out time);
            bool repeats = false;
            bool.TryParse(data3, out repeats);

            switch (a)
            {
            case CustomAction.ActionTypes.Spawn:
            {
                Spawn  s       = go.AddComponent <Spawn>();
                string rfidKey = data4;

                if (database.ContainsKey(rfidKey))
                {
                    s.toSpawn = database[rfidKey].first;
                }
                else
                {
                    string url = "http://" + databaseAddress + "/playtime/getComponents.php";
                    yield return(StartCoroutine(pollDatabase(url, rfidKey, false)));

                    if (database.ContainsKey(rfidKey))
                    {
                        s.toSpawn = database[rfidKey].first;
                    }
                }

                int spawnCount = 0;
                Int32.TryParse(data5, out spawnCount);
                s.setMaxSpawnCount(spawnCount);
                tt.actions.Add(s);
                tt.originalTimes.Add(time);
                tt.repeats.Add(repeats);
            }
            break;

            case CustomAction.ActionTypes.Despawn:
            {
                Despawn d = go.AddComponent <Despawn>();
                tt.actions.Add(d);
                tt.originalTimes.Add(time);
                tt.repeats.Add(repeats);
            }
            break;

            case CustomAction.ActionTypes.Transfigure:
            {
                Transfigure t = go.GetComponent <Transfigure>();
                if (t == null)
                {
                    t = go.AddComponent <Transfigure>();
                }
                bool repeatable;
                Boolean.TryParse(data5, out repeatable);
                List <string> tags = new List <string>();
                t.addTargetAnimControllerAndTags(data4, tags, tags, repeatable, tt.actions.Count);
                tt.actions.Add(t);
                tt.originalTimes.Add(time);
                tt.repeats.Add(repeats);
            }
            break;

            case CustomAction.ActionTypes.DespawnOther:
            {
                DespawnOther dOther = go.AddComponent <DespawnOther>();
                tt.actions.Add(dOther);
                tt.originalTimes.Add(time);
                tt.repeats.Add(repeats);
            }
            break;

            case CustomAction.ActionTypes.RespawnOther:
            {
                RespawnOther rOther = go.AddComponent <RespawnOther>();
                tt.actions.Add(rOther);
                tt.originalTimes.Add(time);
                tt.repeats.Add(repeats);
            }
            break;

            case CustomAction.ActionTypes.Damage:
            {
                Damage d = go.AddComponent <Damage>();
                Int32.TryParse(data4, out d.dmg);
                tt.actions.Add(d);
                tt.originalTimes.Add(time);
                tt.repeats.Add(repeats);
            }
            break;
            }
        }
        break;

        case "DeathTrigger":
        {
            DeathTrigger dt = go.GetComponent <DeathTrigger>();
            if (dt == null)
            {
                dt = go.AddComponent <DeathTrigger>();
            }
            CustomAction.ActionTypes a = (CustomAction.ActionTypes)Enum.Parse(typeof(CustomAction.ActionTypes), data1);

            switch (a)
            {
            case CustomAction.ActionTypes.Spawn:
            {
                Spawn  s       = go.AddComponent <Spawn>();
                string rfidKey = data2;

                if (database.ContainsKey(rfidKey))
                {
                    s.toSpawn = database[rfidKey].first;
                }
                else
                {
                    string url = "http://" + databaseAddress + "/playtime/getComponents.php";
                    yield return(StartCoroutine(pollDatabase(url, rfidKey, false)));

                    if (database.ContainsKey(rfidKey))
                    {
                        s.toSpawn = database[rfidKey].first;
                    }
                }

                int spawnCount = 0;
                Int32.TryParse(data3, out spawnCount);
                s.setMaxSpawnCount(spawnCount);
                s.spawnUnderParent = true;
                dt.actions.Add(s);
            }
            break;

            default:
                break;
            }
        }
        break;

        case "Invisible":
        {
            Invisible i = go.AddComponent <Invisible>();
            i.reset();
        }
        break;

        case "MoveHorizontalUntilCollision":
        {
            MoveHorizontalUntilCollision m = go.AddComponent <MoveHorizontalUntilCollision>();
            List <String> ignoredTags;
            string[]      delimiters = { "|" };
            string[]      tags       = data1.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
            ignoredTags    = new List <string>(tags);
            m.tagsToIgnore = ignoredTags;
        }
        break;

        case "Spawn":
        {
            Spawn  s       = go.AddComponent <Spawn>();
            string rfidKey = data1;

            if (database.ContainsKey(rfidKey))
            {
                s.toSpawn = database[rfidKey].first;
            }
            else
            {
                string url = "http://" + databaseAddress + "/playtime/getComponents.php";
                yield return(StartCoroutine(pollDatabase(url, rfidKey, false)));

                if (database.ContainsKey(rfidKey))
                {
                    s.toSpawn = database[rfidKey].first;
                }
            }

            int spawnCount = 0;
            int.TryParse(data2, out spawnCount);
            s.setMaxSpawnCount(spawnCount);
        }
        break;

        case "Despawn":
        {
            Despawn d = go.AddComponent <Despawn>();
            int     deathAnimID;
            int.TryParse(data1, out deathAnimID);
            d.deathAnimID        = deathAnimID;
            d.defaultDeathAnimID = deathAnimID;
        }
        break;

        case "ChildObject":
        {
            string     rfidKey = data1;
            GameObject child, staticChild;

            if (database.ContainsKey(rfidKey))
            {
                child       = database[rfidKey].first;
                staticChild = database[rfidKey].second;
            }
            else
            {
                string url = "http://" + databaseAddress + "/playtime/getComponents.php";
                yield return(StartCoroutine(pollDatabase(url, rfidKey, false)));

                if (database.ContainsKey(rfidKey))
                {
                    child       = database[rfidKey].first;
                    staticChild = database[rfidKey].second;

                    Vector2 offset = new Vector2();
                    float.TryParse(data2, out offset.x);
                    float.TryParse(data3, out offset.y);

                    child.transform.parent        = go.transform;
                    child.transform.localPosition = offset;
                    child.SetActive(true);
                    staticChild.transform.parent        = staticGO.transform;
                    staticChild.transform.localPosition = offset;
                    staticChild.SetActive(true);
                }
            }
        }
        break;

        case "JumpAI":
        {
            go.AddComponent <JumpAI>();
        }
        break;

        case "Chase":
        {
            go.AddComponent <Chase>();
        }
        break;

        case "Shoot":
        {
            Shoot  s       = go.AddComponent <Shoot>();
            string rfidKey = data1;

            if (database.ContainsKey(rfidKey))
            {
                s.projectile = database[rfidKey].first;
            }
            else
            {
                string url = "http://" + databaseAddress + "/playtime/getComponents.php";
                yield return(StartCoroutine(pollDatabase(url, rfidKey, false)));

                if (database.ContainsKey(rfidKey))
                {
                    s.projectile = database[rfidKey].first;
                }
            }
            float.TryParse(data2, out s.projectileSpeed);
        }
        break;

        case "Color":
        {
            ColorComponent c = go.AddComponent <ColorComponent>();
            float.TryParse(data1, out c.r);
            float.TryParse(data2, out c.g);
            float.TryParse(data3, out c.b);
            float.TryParse(data4, out c.a);
        }
        break;

        default:
            print("Component " + name + " is undefined.");
            break;
        }
    }
Esempio n. 18
0
 /// <summary>
 /// 重新加载所有配置文件
 /// </summary>
 public static void ReLoad(Invisible invisible)
 {
     PerformBadly();
 }
Esempio n. 19
0
 void Start()
 {
     _invisible = GameObject.Find("Invisible(Clone)").GetComponent <Invisible>();
 }
Esempio n. 20
0
    private void specialPlacementLogic(GameObject g, GameObject sg = null, GameObject oldG = null)
    {
        if (sg != null)
        {
            // Special behaviour for Resize component
            Resize r = sg.GetComponent <Resize>();
            if (r != null)
            {
                r.nonStatic = g;
            }
        }

        // Special behaviour for CollideTrigger component
        CollideTrigger ct = g.GetComponent <CollideTrigger>();

        if (ct != null)
        {
            ct.initialize();
        }

        if (oldG != null)
        {
            Transfigure oldT = oldG.GetComponent <Transfigure>();
            if (oldT != null)
            {
                Transfigure t = g.GetComponent <Transfigure>();
                t.targetAndTags.Clear();
                foreach (TargetAnimControllerAndTags tar in oldT.targetAndTags)
                {
                    TargetAnimControllerAndTags newTar = new TargetAnimControllerAndTags();
                    newTar.targetAnimController = tar.targetAnimController;
                    newTar.includedTags         = new List <string>(tar.includedTags);
                    newTar.excludedTags         = new List <string>(tar.excludedTags);
                    newTar.repeatable           = tar.repeatable;
                    newTar.id   = tar.id;
                    newTar.done = false;
                    t.targetAndTags.Add(newTar);
                }
            }
        }

        TimeTrigger tt = g.GetComponent <TimeTrigger>();

        if (tt != null)
        {
            tt.initialize();
        }

        MoveHorizontalUntilCollision mh = g.GetComponent <MoveHorizontalUntilCollision>();

        if (mh != null)
        {
            mh.run();
        }

        KoopaTroopa kt = g.GetComponent <KoopaTroopa>();

        if (kt != null)
        {
            addResetListener(kt);
        }

        FirePower fp = g.GetComponent <FirePower>();

        if (fp != null)
        {
            addResetListener(fp);
        }

        Invisible i = g.GetComponent <Invisible>();

        if (i != null)
        {
            addResetListener(i);
        }
    }