public void Awake()
 {
     owner = GetComponent <AgentAI>();
     Assert.IsNotNull(owner, "Missing owner AgentAI");
     Assert.IsTrue(sightRange > 0f, "Too small sightRange");
     visibleTargets = new List <GameObject>();
 }
Beispiel #2
0
    void Awake()
    {
        instance = this;

        board   = BoardGo.GetComponent <Board>();
        agentAI = AgentGo.GetComponent <AgentAI>();
        rules   = new Rules(board);
    }
Beispiel #3
0
 public void RespawnAgent(AgentAI a)
 {
     if (!a.IsInDanger && !a.m_Dead && !a.IsDowned)
     {
         AgentAI.AgentClass aClass = a.GetClass();
         a.RespawnAtCurrentLocation();
         a = AgentAI.GetAgent(aClass);
         a.SetSelected(true);
         Manager.GetInputManager().Select(a.m_UID.GetSUID(), true);
         //Manager.GetInputManager().sele
     }
 }
Beispiel #4
0
    void SelectAbilities(AgentAI a)
    {
        string[] aNames; int[] aIds;
        a.GetAbilities().m_AbilityManager.GetAbilityNamesAndIDs(out aIds, out aNames);
        for (int i = 0; i < aIds.Length; i++)
        {
            if (a.GetAbilities() != null && a.GetAbilities().GetAbility(aIds[i]) != null)
            {
                try
                {
                    if (a.GetAbilities().HasAbility(aIds[i]))
                    {
                        Ability abil    = a.GetAbilities().GetAbility(aIds[i]);
                        KeyCode keycode = KeyRemapper.GetMappingForAbility(aIds[i]).m_Key;

                        switch (abil.State)
                        {
                        case Ability.AbilityState.prepped:
                            Keyboard.Instance[keycode.ToKey()] = UnityEngine.Color.yellow.ToColore();
                            break;

                        case Ability.AbilityState.activating:
                            Keyboard.Instance[keycode.ToKey()] = UnityEngine.Color.gray.ToColore();
                            break;

                        case Ability.AbilityState.active:
                            Keyboard.Instance[keycode.ToKey()] = UnityEngine.Color.green.ToColore();
                            break;

                        case Ability.AbilityState.ready:
                            Keyboard.Instance[keycode.ToKey()] = UnityEngine.Color.white.ToColore();
                            break;

                        default:
                            Keyboard.Instance[keycode.ToKey()] = magenta;
                            break;
                        }

                        if (abil.GetCooldownPercentage() > 0)
                        {
                            Keyboard.Instance[keycode.ToKey()] = a.IsSelected() ? UnityEngine.Color.yellow.ToColore() : magenta;
                        }
                        else if (abil.GetAmmoCount() == 0 && abil.GetMaxAmmo() != 0 && abil.GetCooldownPercentage() > 0)
                        {
                            Keyboard.Instance[keycode.ToKey()] = a.IsSelected() ? UnityEngine.Color.red.ToColore() : magenta;
                        }
                    }
                }
                catch { }
            }
        }
    }
 public void DetectTargets()
 {
     visibleTargets.Clear();
     Collider[] collidersInRange = Physics.OverlapSphere(transform.position, sightRange);
     foreach (Collider collider in collidersInRange)
     {
         AgentAI agent = collider.GetComponent <AgentAI>();
         if (agent != null && agent != owner && agent.team != owner.team)
         {
             visibleTargets.Add(agent.gameObject);
         }
     }
 }
Beispiel #6
0
    public void Start()
    {
        teamSeeds = new int[4];
        seedMem   = new int[5];
        cloneMem  = new Clone[5];
        clones    = new Clone[5];

        int n = 0;

        foreach (AgentAI a in AgentAI.GetAgents())
        {
            teamSeeds[n] = CloneManager.Get().GetCloneableData(a.CurrentCloneableId).m_RandomSeed;
            clones[n]    = new Clone(a.CurrentCloneableId);
            a.AddAmmo(50);
            seedMem[n + 1]  = CloneManager.Get().GetCloneableData(a.CurrentCloneableId).m_RandomSeed;
            cloneMem[n + 1] = new Clone(a.CurrentCloneableId);
            n++;
        }
    }
        void StopSaves()
        {
            if (!SaveGame.CurrentUser.UserConfiguration.IronmanMode)
            {
                return;
            }

            System.Collections.Generic.List <AgentAI> agents = AgentAI.GetAgents();
            foreach (AgentAI agentAI in agents)
            {
                agentAI.gameObject.AddComponent(typeof(OnAgentDeath));
            }
            //int agentCount = Manager.GetAIWorld().m_AgentPrefabs.Keys.Count();
            //Manager.GetUIManager().ShowMessagePopup($"You current have {agentCount} agents", 3);
            //var TestSaveGlobals = new TestSaveGlobals();
            //var save = new SaveComponentBase();
            Manager.m_DevModeEnabled = true;

            //LoadSavePanelUi.SaveGameListUi.m_LoadSaveButton.gameObject.SetActive(false);
        }
Beispiel #8
0
 void DeselectAbilities(AgentAI a)
 {
     string[] aNames; int[] aIds;
     a.GetAbilities().m_AbilityManager.GetAbilityNamesAndIDs(out aIds, out aNames);
     for (int i = 0; i < aIds.Length; i++)
     {
         if (a.GetAbilities() != null && a.GetAbilities().GetAbility(aIds[i]) != null)
         {
             try
             {
                 if (a.GetAbilities().HasAbility(aIds[i]))
                 {
                     Ability abil    = a.GetAbilities().GetAbility(aIds[i]);
                     KeyCode keycode = KeyRemapper.GetMappingForAbility(aIds[i]).m_Key;
                     Keyboard.Instance[keycode.ToKey()] = magenta;
                 }
             }
             catch { }
         }
     }
 }
Beispiel #9
0
    /// <summary>
    /// Called once per frame.
    /// </summary>
    public void Update()
    {
        if (Manager.Get().GameInProgress)
        {
            if (Input.GetKeyDown(KeyCode.Delete))
            {
                try
                {
                    List <AgentAI> agents  = AgentAI.GetAgents();
                    AgentAI        soldier = agents[0];

                    Abilities abilities = soldier.GetAbilities();

                    Manager.GetUIManager().ShowMessagePopup(abilities.ToString());
                    abilities.AddAbility(999);
                }
                catch (Exception e)
                {
                    Debug.Log(e.Message + "\n" + e.StackTrace);
                    Manager.GetUIManager().ShowMessagePopup(e.Message);
                }
            }
        }
    }
Beispiel #10
0
    /// <summary>
    /// Called once per frame.
    /// </summary>
    public void Update()
    {
        if (Manager.Get().GameInProgress)
        {
            if (Input.GetKeyDown(KeyCode.M))
            {
                foreach (AgentAI a in AgentAI.GetAgents())
                {
                    if (a.IsSelected())
                    {
                        if (CloneManager.Get().GetCloneableData(a.CurrentCloneableId).Sex == WardrobeManager.Sex.Female)
                        {
                            CloneManager.Get().GetCloneableData(a.CurrentCloneableId).Sex = WardrobeManager.Sex.Male;
                        }
                        else
                        {
                            CloneManager.Get().GetCloneableData(a.CurrentCloneableId).Sex = WardrobeManager.Sex.Female;
                        }
                        //CloneManager.Get().GetCloneableData(a.CurrentCloneableId).m_RandomSeed -= 10;
                        RespawnAgent(a);
                    }
                }
            }

            if (Input.GetKeyDown(KeyCode.End))
            {
                string info = "";
                int    n    = 0;
                foreach (AgentAI a in Manager.GetInputControl().GetSelectedAgents())
                {
                    //CloneManager.Get().GetCloneableData(a.CurrentCloneableId).m_RandomSeed = teamSeeds[n];
                    clones[n].ApplyClone(a.CurrentCloneableId);
                    RespawnAgent(a);

                    if (info != "")
                    {
                        info += "\n";
                    }
                    info += a.AgentClassName() + " got " + clones[n].GetInfo();
                    n++;
                }
                setEntityInfo("Agent Clone Data applied", info);
            }

            if (Input.GetKeyDown(KeyCode.Home))
            {
                string info = "";
                int    n    = 0;
                foreach (AgentAI a in AgentAI.GetAgents())
                {
                    //copyClone(CloneManager.Get().GetCloneableData(a.CurrentCloneableId), ref clones[n]);
                    teamSeeds[n] = CloneManager.Get().GetCloneableData(a.CurrentCloneableId).m_RandomSeed;
                    if (clones.Length != 5)
                    {
                        clones = new Clone[5];
                    }
                    clones[n] = new Clone(a.CurrentCloneableId);
                    if (info != "")
                    {
                        info += "\n";
                    }
                    info += a.AgentClassName() + " info: " + clones[n].GetInfo();
                    n++;
                }
                setEntityInfo("Agent Clone Data Stored", info);
            }

            if ((Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftControl)) && Input.GetKeyDown(KeyCode.Keypad1))
            {
                memSet(1);
            }
            else if ((Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftControl)) && Input.GetKeyDown(KeyCode.Keypad2))
            {
                memSet(2);
            }
            else if ((Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftControl)) && Input.GetKeyDown(KeyCode.Keypad4))
            {
                memGet(1);
            }
            else if ((Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftControl)) && Input.GetKeyDown(KeyCode.Keypad5))
            {
                memGet(2);
            }
            else if (Input.GetKeyDown(KeyCode.Keypad1))
            {
                memSet(1);
            }
            else if (Input.GetKeyDown(KeyCode.Keypad2))
            {
                memSet(2);
            }
            else if (Input.GetKeyDown(KeyCode.Keypad3))
            {
                memSet(3);
            }
            else if (Input.GetKeyDown(KeyCode.Keypad4))
            {
                memGet(1);
            }
            else if (Input.GetKeyDown(KeyCode.Keypad5))
            {
                memGet(2);
            }
            else if (Input.GetKeyDown(KeyCode.Keypad6))
            {
                memGet(3);
            }

            if (Input.GetKeyDown(KeyCode.Keypad8))
            {
                string info = "";
                foreach (AgentAI a in AgentAI.GetAgents())
                {
                    if (a.IsSelected())
                    {
                        int numberOfWardrobeTypes = System.Enum.GetValues(typeof(WardrobeManager.WardrobeType)).Length;
                        int typeNo = UnityEngine.Random.Range(0, numberOfWardrobeTypes);
                        WardrobeManager.WardrobeType wType = (WardrobeManager.WardrobeType)typeNo;
                        //a.name = "Caldor";
                        //a.InitRandomSeed();
                        //a.m_Identity.NameID = IdentityManager.GetRandomNameID(CloneManager.Get().GetCloneableData(a.CurrentCloneableId).Sex);
                        CloneManager.Get().GetCloneableData(a.CurrentCloneableId).m_RandomSeed = Wardrobe.GenerateRandomSeed();
                        a.m_Wardrobe.m_Sex          = Wardrobe.GenerateRandomSex();
                        a.m_Wardrobe.m_WardrobeType = wType;
                        //a.m_Wardrobe.bod = Wardrobe.CreateRandomBodyData();
                        Wardrobe.BodyData body = a.m_Wardrobe.GetBodyData();
                        //body.m_HairColor1 = Color.yellow;
                        //body.m_HairColor2 = Color.green;
                        //body.m_LowerPrimaryColor = Color.red;
                        //body.m_LowerSecondaryColor = Color.red;
                        //body.m_SkinColor = Color.blue;
                        //a.m_Wardrobe.SetBodyData(body, a.m_Wardrobe.m_Sex, a.m_Wardrobe.RandomSeed, a.m_Wardrobe.m_WardrobeType);
                        RespawnAgent(a);

                        info += "Hair:" + body.m_HairColor1.ToString() + " & " + body.m_HairColor2.ToString() + ". skin: " + body.m_SkinColor.ToString();
                    }
                }
                setEntityInfo("Randomized", info);
            }

            if ((Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftControl)) && Input.GetKeyDown(KeyCode.Keypad9))
            {
                int numberOfWardrobeTypes = System.Enum.GetValues(typeof(WardrobeManager.WardrobeType)).Length;
                int typeNo = UnityEngine.Random.Range(0, numberOfWardrobeTypes);
                WardrobeManager.WardrobeType wType = (WardrobeManager.WardrobeType)typeNo;
                foreach (AgentAI a in Manager.GetInputControl().GetSelectedAgents())
                {
                    a.m_Wardrobe.m_WardrobeType = wType;
                    RespawnAgent(a);
                }
            }
            else if (Input.GetKeyDown(KeyCode.Keypad9))
            {
                string info = "";
                string first; string last;
                foreach (AgentAI a in Manager.GetInputControl().GetSelectedAgents()) //AgentAI.GetAgents())
                {
                    int           nameId        = IdentityManager.GetRandomNameID(a.m_Wardrobe.m_Sex);
                    int           currentNameId = Mathf.RoundToInt(a.CurrentCloneableId);
                    int           cloneId       = a.CurrentCloneableId;
                    CloneableData cData         = CloneManager.Get().GetCloneableData(cloneId);
                    IdentityManager.Get().GetName(cData.IdentityId, out first, out last);
                    info += "Name based on identity Id: " + cData.IdentityId + " is " + first + " " + last + "\n";
                    //info += "Clonable name: " + a.GetCloneable().name + "\n";
                    info += currentNameId + ": " + first + " " + last;
                    IdentityManager.Get().GetName(cData.m_IdentityID, out first, out last);
                    //a.m_Identity.NameID = nameId;
                    //a.m_Wardrobe.m_WardrobeType = WardrobeManager.WardrobeType.AgentSupportBacker;
                    info += " changing name To " + nameId + ": " + first + " " + last + "\n";
                    Manager.GetUIManager().ShowMessagePopup(info, 6);
                    cData.IdentityId   = nameId;
                    cData.m_IdentityID = nameId;
                    //cData.WardrobeType = WardrobeManager.WardrobeType.Prostitute2;

                    //a.name = "Caldor";
                    //a.InitRandomSeed();
                    //a.m_Identity.NameID = IdentityManager.GetRandomNameID(CloneManager.Get().GetCloneableData(a.CurrentCloneableId).Sex);
                    //CloneManager.Get().GetCloneableData(a.CurrentCloneableId).m_RandomSeed = Wardrobe.GenerateRandomSeed();
                    //a.m_Wardrobe.m_Sex = WardrobeManager.Sex.Male;
                    //a.m_Wardrobe.bod = Wardrobe.CreateRandomBodyData();
                    Wardrobe.BodyData body = a.m_Wardrobe.GetBodyData();
                    //body.m_HairColor1 = Color.black;
                    //body.m_HairColor2 = Color.black;
                    //body.m_LowerPrimaryColor = Color.black;
                    //body.m_LowerSecondaryColor = Color.black;
                    //body.m_SkinColor = Color.black;

                    //a.m_Wardrobe.SetBodyData(body, a.m_Wardrobe.m_Sex, a.m_Wardrobe.RandomSeed, a.m_Wardrobe.m_WardrobeType);
                    RespawnAgent(a);

                    info += a.AgentClassName() + " got Hair: " + body.m_HairColor1 + " & " + body.m_HairColor1 + ".\nskin: " + body.m_SkinColor;
                    info += "\nWardrope type: " + a.m_Wardrobe.m_WardrobeType + "\n";
                }
                setEntityInfo("Selected agent", info);
            }



            if (Input.GetKeyDown(KeyCode.Keypad0))
            {
                string  info = "";
                string  first; string last;
                AgentAI a = AgentAI.FirstSelectedAgentAi();
                if (a != null)
                {
                    int           cloneId = a.CurrentCloneableId;
                    CloneableData cData   = CloneManager.Get().GetCloneableData(cloneId);
                    IdentityManager.Get().GetName(cData.IdentityId, out first, out last);

                    info += "Selected person is " + first + " " + last + ", gender " + cData.Sex;
                    info += ". Seed is:" + cData.RandomSeed + ", mSeed is:" + cData.m_RandomSeed + " and wardrobe type is " + cData.WardrobeType;
                    info += ". Palette: " + cData.WardrobeConfigurationData.m_DefaultColorPaletteName;
                }
                else
                {
                    foreach (AIEntity ae in AIEntity.FindObjectsOfType(typeof(AIEntity)))
                    {
                        if (ae.IsSelected())
                        {
                            ae.m_IsControllable = true;
                            IdentityManager.Get().GetName(ae.m_Identity.NameID, out first, out last);
                            info += "Selected person is " + first + " " + last + ", gender " + ae.m_Wardrobe.m_Sex;
                            info += ". Seed is:" + ae.m_Wardrobe.RandomSeed + " Wardrobe type is " + ae.m_Wardrobe.m_WardrobeType;
                            info += ". Palette: " + ae.m_Wardrobe.DefaultColorPaletteName;
                            break;
                        }
                    }
                }
                setEntityInfo("Selected AI info", info);
            }
        }
    }
Beispiel #11
0
    public void memGet(int n)
    {
        bool    done = false;
        string  info = "";
        AgentAI ai   = null;

        foreach (AgentAI a in AgentAI.GetAgents())
        {
            if (a.IsSelected() && (Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftControl)))
            {
                a.m_Identity.NameID = nameIDs[n];
            }
            else if (a.IsSelected() && cloneMem[n] != null)
            {
                cloneMem[n].ApplyClone(a.CurrentCloneableId);
                //a.m_Wardrobe.CopyFrom();
                //a.RespawnAtCurrentLocation();
                RespawnAgent(a);
                info += "Clone seed: " + cloneMem[n].seed;
                done  = true;
            }
            else if (a.IsSelected() && 2 < seedMem[n])
            {
                //applyClone(cloneMem[n], a.CurrentCloneableId);
                CloneManager.Get().GetCloneableData(a.CurrentCloneableId).m_RandomSeed = seedMem[n];

                //a.RespawnAtCurrentLocation();
                RespawnAgent(a);
                //break;
                info += "Seed: " + seedMem[n];
                done  = true;
            }
        }

        if (cloneMem[1] != null)
        {
            info += "Seed 1: " + cloneMem[1].seed;
        }
        if (cloneMem[2] != null)
        {
            info += "\nSeed 2: " + cloneMem[2].seed;
        }
        if (cloneMem[3] != null)
        {
            info += "\nSeed 3: " + cloneMem[3].seed;
        }
        setEntityInfo("Seeds in memory: ", info);

        if (done)
        {
            Manager.GetUIManager().ShowMessagePopup("Clone seed " + n + ": " + cloneMem[n].seed + " put into" + ai.AgentClassName(), 8);
        }
        else
        {
            string first; string last;
            if (Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftControl) && nameIDs[n] != 0)
            {
                IdentityManager.Get().GetName(nameIDs[n], out first, out last);
                Manager.GetUIManager().ShowMessagePopup("NameId " + nameIDs[n] + " from nameId mem slot " + n + ", name " + first + " " + last + " applied.", 8);
            }
            else
            {
                IdentityManager.Get().GetName(cloneMem[n].nameId, out first, out last);
                Manager.GetUIManager().ShowMessagePopup("Clone seed " + n + ": " + cloneMem[n].seed + " name id: " + cloneMem[n].nameId + ", name " + first + " " + last, 8);
            }
        }
    }
Beispiel #12
0
    public void memSet(int n)
    {
        int   seed = 0;
        Clone c    = null;

        foreach (AgentAI a in AgentAI.GetAgents())
        {
            if (a.IsSelected() && (Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftControl)))
            {
                nameIDs[n] = a.m_Identity.NameID;
            }
            else if (a.IsSelected())
            {
                c    = new Clone(a.CurrentCloneableId);
                seed = c.seed;
            }
        }
        //CloneableData data = null;
        if (seed != 0)
        {
            seedMem[n] = seed;
        }
        else
        {
            foreach (AIEntity ae in AIEntity.FindObjectsOfType(typeof(AIEntity)))
            {
                //if (a.IsSelected())
                //    seedMem[n] = a.GetComponent<CloneableData>().RandomSeed;
                //CloneManager.Get().GetCloneableData(a.CurrentCloneableId).m_RandomSeed;
                if (ae.IsSelected() && (Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftControl)))
                {
                    nameIDs[n] = ae.m_Identity.NameID;
                }
                else if (ae.IsSelected())
                {
                    c    = new Clone(ae);
                    seed = ae.m_Wardrobe.RandomSeed;
                    //w = new Wardrobe();
                    //w.CopyFrom(a.m_Wardrobe);

                    //data = CloneManager.Get().NewCloneableFromPrefab(a);
                    //if (a.GetComponentInParent<CloneableData>() != null)
                    //    seed = a.GetCloneable().GetComponentInParent<CloneableData>().m_RandomSeed;
                    //if (a.GetComponent<CloneableData>() != null)
                    //    seed = a.GetComponent<CloneableData>().m_RandomSeed;
                    //if (a.GetCloneable().GetComponentInChildren<CloneableData>() != null)
                    //    seed = a.GetCloneable().GetComponentInChildren<CloneableData>().m_RandomSeed;
                    //if (seed == 0)
                    //    seed = data.m_RandomSeed;
                }
            }
        }
        if (seed != 0)
        {
            seedMem[n] = seed;
        }
        string info = "Seed: " + seed;

        if (c != null)
        {
            cloneMem[n] = c;
            Manager.GetUIManager().ShowMessagePopup(info + " saved into " + n, 8);
            setEntityInfo("Seed saved into " + n, info);
        }
        else if (Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftControl) && nameIDs[n] != 0)
        {
            string first; string last;
            IdentityManager.Get().GetName(nameIDs[n], out first, out last);
            Manager.GetUIManager().ShowMessagePopup("NameId:" + nameIDs[n] + " put in nameId mem slot " + n + ", name " + first + " " + last, 8);
        }
        else
        {
            Manager.GetUIManager().ShowMessagePopup("Cannot store a clone in slot " + n + " if no clonable person is selected.", 8);
        }
    }
Beispiel #13
0
    GameObject CreateTile(int x, int y, Level level)
    {
        TileType tt = level.GetTileType(x, y);

        if (tt == TileType.WALL)
        {
            GameObject go;
            if (level.IsWallTileContained(x, y))
            {
                // all neighbours are walls -> no collision required
                go = (GameObject)Instantiate(tileNC);
            }
            else
            {
                go = (GameObject)Instantiate(tile);
            }
            WallTile wt = go.GetComponent <WallTile>();
            wt.SetTile(level.GetWallTileIndex(x, y));
            return(go);
        }
        else if (tt == TileType.PLAYER)
        {
            //return (GameObject)Instantiate(player);
            if (Globals.player != null)
            {
                Globals.player.transform.position = new Vector3(x, y, 0);
            }
            return(null);
        }
        else if (tt == TileType.AGENT)
        {
            GameObject go = (GameObject)Instantiate(agent);
            AgentAI    ai = go.GetComponent <AgentAI>();
            ai.Home = new Vector2(x, y);
            return(go);
        }
        else if (tt == TileType.DRONE)
        {
            GameObject go = (GameObject)Instantiate(drone);
            Drone      ai = go.GetComponent <Drone>();
            ai.Home = new Vector2(x, y);
            return(go);
        }
        else if (tt == TileType.MACHINE)
        {
            GameObject go = (GameObject)Instantiate(machine);
            go.transform.localPosition = new Vector2(0.5f, 1.0f);
            return(go);
        }
        else if (tt == TileType.PORTAL_0)
        {
            GameObject go = (GameObject)Instantiate(portal);
            go.transform.localPosition       = new Vector2(2.0f, 2.0f);
            go.GetComponent <Portal>().level = 0;
            return(go);
        }
        else if (tt == TileType.PORTAL_1)
        {
            GameObject go = (GameObject)Instantiate(portal);
            go.transform.localPosition       = new Vector2(2.0f, 2.0f);
            go.GetComponent <Portal>().level = 1;
            return(go);
        }
        else if (tt == TileType.PORTAL_2)
        {
            GameObject go = (GameObject)Instantiate(portal);
            go.transform.localPosition       = new Vector2(2.0f, 2.0f);
            go.GetComponent <Portal>().level = 2;
            return(go);
        }
        else if (tt == TileType.PORTAL_3)
        {
            GameObject go = (GameObject)Instantiate(portal);
            go.transform.localPosition       = new Vector2(2.0f, 2.0f);
            go.GetComponent <Portal>().level = 3;
            return(go);
        }
        else if (tt == TileType.PORTAL_4)
        {
            GameObject go = (GameObject)Instantiate(portal);
            go.transform.localPosition       = new Vector2(2.0f, 2.0f);
            go.GetComponent <Portal>().level = 4;
            return(go);
        }
        else if (tt == TileType.PORTAL_5)
        {
            GameObject go = (GameObject)Instantiate(portal);
            go.transform.localPosition       = new Vector2(2.0f, 2.0f);
            go.GetComponent <Portal>().level = 5;
            return(go);
        }
        else if (tt == TileType.PORTAL_6)
        {
            GameObject go = (GameObject)Instantiate(portal);
            go.transform.localPosition       = new Vector2(2.0f, 2.0f);
            go.GetComponent <Portal>().level = 6;
            return(go);
        }
        else if (tt == TileType.PORTAL_7)
        {
            GameObject go = (GameObject)Instantiate(portal);
            go.transform.localPosition       = new Vector2(2.0f, 2.0f);
            go.GetComponent <Portal>().level = 7;
            return(go);
        }
        else
        {
            return(null);
        }
    }
Beispiel #14
0
 public void Awake()
 {
     owner = GetComponent <AgentAI>();
     Assert.IsNotNull(owner, "Missing owner");
     Assert.IsNotNull(weapon, "Missing weapon");
 }
        public void Update()
        {
            if (Manager.Get().IsLoading())
            {
                shownModInfo = false;
            }

            //Check if unstuck is ready
            if (Manager.Get().GameInProgress)
            {
                if (timer < Time.time)
                {
                    AIEntity spawnLocation = null;
                    if (Input.GetKeyDown(KeyCode.F11) || Input.GetKeyDown(KeyCode.Minus))
                    {
                        foreach (AgentAI a in AgentAI.GetAgents())
                        {
                            if (a.IsDowned)
                            {
                                a.RespawnAt(Manager.GetInputControl().GetClosestPos(a.transform.position), spawnLocation.transform.rotation);
                            }
                            //a.RespawnAt(spawnLocation.transform.position, spawnLocation.transform.rotation);
                            else
                            {
                                a.transform.position = Manager.GetInputControl().GetClosestPos(a.transform.position);
                            }
                            //a.Teleport(spawnLocation.transform);
                        }
                        timer = Time.time + 120;
                        Manager.GetUIManager().ShowMessagePopup("All agents unstuck. Now the unstuck function will be disabled for 2 minutes", 3);
                    }
                }
                else if (Input.GetKeyDown(KeyCode.F11))
                {
                    int secondsLeft = Mathf.RoundToInt(timer - Time.time);
                    int minutesLeft = secondsLeft / 60;
                    secondsLeft -= (minutesLeft * 60);
                    Manager.GetUIManager().ShowMessagePopup("Unstuck function locked." + " There is " + minutesLeft + " minutes and " + secondsLeft + " seconds until the UnStuck function is ready again.", 7);
                    //setEntityInfo("Unstuck function unnavailable", "There is " + minutesLeft + " minutes and " + secondsLeft + " seconds until the UnStuck function is ready again.");
                }
            }

            if (Manager.Get().GameInProgress)
            {
                if (!shownModInfo)
                {
                    shownModInfo = true;
                    if (SaveGame.CurrentUser.UserConfiguration.IronmanMode)
                    {
                        ironmanMode = true;
                        StopSaves();
                        Manager.GetUIManager().DoModalMessageBox("PermaDeath!", "Ultimate Ironman Gamemode Mod is active. Beware that this mod deletes your savegames if an agent dies, removes the agent and then autosaves. Good luck and have fun", InputBoxUi.InputBoxTypes.MbOk);
                        //+ string.Join(",", Manager.GetPluginManager().LoadedPlugins.Select(p => p.FullPath).ToArray())
                    }
                    else
                    {
                        ironmanMode = false;
                    }
                }
                if (ironmanMode && autoSaveTimer < Time.time)
                {
                    autoSaveTimer = Time.time + 150;
                    DeleteAllSaves();
                    Manager.Get().DoSaveGame(0);
                    Manager.Get().AutoSave();
                    Manager.DoSaveAuto();
                }

                if (Input.GetKeyDown(KeyCode.Pause))
                {
                    if (m_TacticalPauseTimeScaler.Paused)
                    {
                        m_TacticalPauseTimeScaler.Reset();
                    }
                    else
                    {
                        m_TacticalPauseTimeScaler.Pause();
                    }
                }
            }
        }
Beispiel #16
0
    /// <summary>
    /// Called once per frame.
    /// </summary>
    public void Update()
    {
        if (Manager.Get().GameInProgress)
        {
            if (firstinit)
            {
                Keyboard.Instance.SetAll(magenta);
                Mouse.Instance.SetAll(magenta);
                Mouse.Instance.SetAll(magenta);
                Headset.Instance.SetAll(magenta);
                ChromaLink.Instance.SetAll(magenta);
                firstinit = false;
            }
            foreach (AgentAI a in AgentAI.GetAgents())
            {
                Key keycode = a.GetSelectionKey().ToKey();

                if (a.IsInCombat())
                {
                    Keyboard.Instance[keycode] = UnityEngine.Color.red.ToColore();
                }
                else if (a.GetHealthState() != Health.HealthState.alive)
                {
                    UpdateKeyColor(keycode, a.GetRespawnTimePct() / 0.5f);
                }
                else if (a.GetHealthState() == Health.HealthState.beingRevived)
                {
                    Keyboard.Instance[keycode] = UnityEngine.Color.blue.ToColore();
                }
                else if (a.Selectable)
                {
                    if (a.IsSelected())
                    {
                        if (!selected_agents.Contains(a))
                        {
                            selected_agents.Add(a);
                        }

                        if (a.GetCurrentWeapon(false) != null)
                        {
                            Keyboard.Instance[keycode] = new Corale.Colore.Core.Color(255, 128, 0);
                        }
                        else
                        {
                            Keyboard.Instance[keycode] = UnityEngine.Color.green.ToColore();
                        }

                        SelectAbilities(a);
                    }
                    else
                    {
                        if (selected_agents.Contains(a))
                        {
                            DeselectAbilities(a);
                            selected_agents.Remove(a);
                        }
                        if (a.GetCurrentWeapon(false) != null)
                        {
                            Keyboard.Instance[keycode] = new Corale.Colore.Core.Color(255, 128, 0);
                        }
                        else
                        {
                            Keyboard.Instance[keycode] = UnityEngine.Color.blue.ToColore();
                        }
                    }
                }
            }

            if (selected_agents.Count > 0)
            {
                Keyboard.Instance[KeyCode.F.ToKey()] = UnityEngine.Color.white.ToColore();
            }
            else
            {
                Keyboard.Instance[KeyCode.F.ToKey()] = magenta;
            }
        }
        else
        {
            Keyboard.Instance.SetAll(new Corale.Colore.Core.Color(57, 255, 20));
            Mouse.Instance.SetAll(new Corale.Colore.Core.Color(57, 255, 20));
            Mousepad.Instance.SetAll(new Corale.Colore.Core.Color(57, 255, 20));
            Headset.Instance.SetAll(new Corale.Colore.Core.Color(57, 255, 20));
            ChromaLink.Instance.SetAll(new Corale.Colore.Core.Color(57, 255, 20));
            firstinit = true;
        }
    }
Beispiel #17
0
    /// <summary>
    /// Called once per frame.
    /// </summary>
    public void Update()
    {
        if (Manager.Get().IsLoading())
        {
            timer = Time.time;
        }

        if (Manager.Get().GameInProgress)
        {
            //Check if unstuck is ready
            if (timer < Time.time)
            {
                AIEntity spawnLocation = null;
                if (Input.GetKeyDown(KeyCode.F11) || Input.GetKeyDown(KeyCode.Minus))
                {
                    foreach (AgentAI a in AgentAI.GetAgents())
                    {
                        if (a.IsDowned || a.m_Dead)
                        {
                            a.RespawnAt(Manager.GetInputControl().GetClosestPos(a.transform.position), spawnLocation.transform.rotation);
                        }
                        //a.RespawnAt(spawnLocation.transform.position, spawnLocation.transform.rotation);
                        else
                        {
                            a.transform.position = Manager.GetInputControl().GetClosestPos(a.transform.position);
                        }
                        //a.Teleport(spawnLocation.transform);
                    }
                    timer = Time.time + 600f;
                    Manager.GetUIManager().ShowMessagePopup("All agents unstuck. Now the unstuck function will be disabled for 10 minutes", 3);
                    //setEntityInfo("Made all agents unstuck", "Now the unstuck function will be disabled for 15 minutes");
                }
            }
            else if (Input.GetKeyDown(KeyCode.F11))
            {
                int secondsLeft = Mathf.RoundToInt(timer - Time.time);
                int minutesLeft = secondsLeft / 60;
                secondsLeft -= (minutesLeft * 60);
                Manager.GetUIManager().ShowMessagePopup("Unstuck function locked." + " There is " + minutesLeft + " minutes and " + secondsLeft + " seconds until the UnStuck function is ready again.", 7);
                //setEntityInfo("Unstuck function unnavailable", "There is " + minutesLeft + " minutes and " + secondsLeft + " seconds until the UnStuck function is ready again.");
            }
            else if (Input.GetKeyDown(KeyCode.Minus))
            {
                AIEntity spawnLocation = null;
                var      selected      = Manager.GetInputManager().GetNonPlayerSelectedEntities();
                selected.AddRange(Manager.GetInputManager().GetPlayerSelectedEntities());
                foreach (AIEntity ae in selected)//AIEntity.FindObjectsOfType(typeof(AIEntity)))
                {
                    if (ae.IsHuman() && ae.IsAddedToWorld && ae.IsSelected())
                    {
                        spawnLocation = ae;
                    }
                }
                if (spawnLocation != null)
                {
                    foreach (AgentAI a in AgentAI.GetAgents())
                    {
                        if (a.IsDowned || a.m_Dead)
                        {
                            a.RespawnAt(spawnLocation.transform.position, spawnLocation.transform.rotation);
                        }
                        else
                        {
                            a.transform.position = spawnLocation.transform.position;
                        }
                        //a.Teleport(spawnLocation.transform);
                    }
                    //timer = Time.time + 900f;
                    Manager.GetUIManager().ShowMessagePopup("All agents should now be unstuck.", 6);
                    //setEntityInfo("Made all agents unstuck", "Now the unstuck function will be disabled for 15 minutes");
                }
                else
                {
                    Manager.GetUIManager().ShowMessagePopup("No unstuck spot selected. You need to select a human as a location for your agents to get moved to, to be unstuck.", 9);
                    //setEntityInfo("No unstuck spot selected", "You need to select a human or a mech as a location for your agents to get moved to, to be unstuck.");
                }
            }

            if (Input.GetKeyDown(KeyCode.F8))
            {
                string info = "";
                foreach (AIEntity ae in Manager.GetInputControl().GetPlayerSelectedEntities())
                {
                    // Standard: Melee, SpeedAdjust, OnlyNearCover
                    ae.m_AIAbilities = (AIAbilities)197672;
                    // Scan, Melee. Shoot, LeaveCover, GetWeaponOut
                    //ae.m_AIAbilities = (AIAbilities)197645;
                    // Scan, Melee. Shoot, LeaveCover, GetWeaponOut, OnlyNearCover
                    //ae.m_AIAbilities = (AIAbilities)197709;

                    info += "\nAgent: " + ae.GetName();
                    info += "\nNow has AIAbilties: " + ae.m_AIAbilities.ToString();
                }
                setEntityInfo("Setting AI abilities", info);
            }

            if (Input.GetKeyDown(KeyCode.F9))
            {
                string info = "";
                foreach (AIEntity ae in Manager.GetInputControl().GetPlayerSelectedEntities())
                {
                    //ae.m_AIAbilities = AIAbilities.LicensedToKill;
                    //ae.m_AIAbilities = AIAbilities.FindBetterCover;
                    //ae.m_AIAbilities = AIAbilities.Shoot;
                    //ae.m_AIAbilities = AIAbilities.OnlyNearCover;
                    //ae.m_AIAbilities = AIAbilities.LeaveCover;
                    //ae.m_AIAbilities = AIAbilities.GetWeaponOut;
                    //AIAbilities.HasSpeedAdjust;
                    //AIAbilities.CanMelee;
                    //AIAbilities.ScanEnemy;

                    // Standard: Melee, SpeedAdjust, OnlyNearCover
                    //ae.m_AIAbilities = (AIAbilities)197672;
                    // Scan, Melee. Shoot, LeaveCover, GetWeaponOut, SpeedAdjust
                    ae.m_AIAbilities = (AIAbilities)197645;
                    // Scan, Melee. Shoot, LeaveCover, GetWeaponOut, OnlyNearCover, SpeedAdjust
                    //ae.m_AIAbilities = (AIAbilities)197709;

                    info += "\nAgent: " + ae.GetName();
                    info += "\nNow has AIAbilties: " + ae.m_AIAbilities.ToString();
                }
                setEntityInfo("Setting AI abilities", info);
            }

            if (Input.GetKeyDown(KeyCode.F10))
            {
                string info = "";
                foreach (AIEntity ae in Manager.GetInputControl().GetPlayerSelectedEntities())
                {
                    info += "\nAgent: " + ae.GetName();
                    info += "\n" + ae.m_AIAbilities.ToString();
                    if (ae.HasAIAbility(AIAbilities.IgnoreBeingShot))
                    {
                        info += "\nIgnores being shot";
                    }
                    else
                    {
                        info += "\nDoes not ignore being shot";
                    }
                    if (ae.HasAIAbility(AIAbilities.LicensedToKill))
                    {
                        info += "\nIs licensed to kill";
                    }
                    else
                    {
                        info += "\nNot licensed to kill";
                    }
                    if (ae.HasAIAbility(AIAbilities.GetWeaponOut))
                    {
                        info += "\nCan get weapon out";
                    }
                    else
                    {
                        info += "\nCannot get weapon out";
                    }
                    if (ae.HasAIAbility(AIAbilities.Shoot))
                    {
                        info += "\nCan shoot";
                    }
                    else
                    {
                        info += "\nCannot shoot";
                    }
                    if (ae.HasAIAbility(AIAbilities.CanMelee))
                    {
                        info += "\nCan melee";
                    }
                    else
                    {
                        info += "\nCannot melee";
                    }
                }
                setEntityInfo("Info about AI abilities", info);
            }
        }
    }
Beispiel #18
0
 public void AddAgent(string user, AgentAI agent)
 {
     _spawnedCubes.Add(user, agent);
 }