Inheritance: MonoBehaviour
Example #1
0
    private void GetNPCInfo()
    {
        if (m_npcID != 0)
        {
            NPCObject obj = NPCList.NPCListObject.GetInformation(m_npcID);
            if (obj == null)
            {
                Debug.Log("[NPC] Couldn't load NPC [" + gameObject.name + "] with ID: " + m_npcID);
            }
            else
            {
                m_npcID              = obj.m_NPCID;
                m_Sex                = obj.m_Sex;
                m_npcName            = obj.m_Name;
                m_Interactable       = obj.m_Interactable;
                TimeBetweenCharacter = obj.m_TalkSpeed;
                m_QuestID            = obj.m_QuestID;
                m_Dialogue           = obj.m_Dialogue;

                Debug.Log("[NPC] Loaded NPC [" + m_npcName + "] with ID: " + m_npcID);
            }
        }
        else
        {
            Debug.Log("[NPC] No valid NPC ID for Game Object: " + gameObject.name);
        }
    }
Example #2
0
        public void Spawn()
        {
            NPCInfo npcInfo = new NPCInfo
            {
                Name     = Info.Name,
                FileName = Info.FileName,
                Location = Info.Location,
                Image    = 1000
            };

            if (Conquest.Guild != null)
            {
                Guild          = Conquest.Guild;
                npcInfo.Image  = Guild.Info.FlagImage;
                npcInfo.Colour = Guild.Info.FlagColour;
            }

            Flag = new NPCObject(npcInfo)
            {
                CurrentMap = Conquest.ConquestMap
            };

            Flag.CurrentMap.AddObject(Flag);

            Flag.Spawned();
        }
Example #3
0
 public Node NPCBehavior_Grab(NPCObject obj)
 {
     return(new Sequence(
                NPCBehavior_LookAt(obj.GetMainLookAtPoint(), true),
                NPCBehavior_GoToAtDistance(new Vector3(obj.GetPosition().x, this.transform.position.y, obj.GetPosition().z), 0.8f),
                new LeafInvoke(() => Behavior_GrabRightHand(obj)),
                new LeafWait(1000),
                NPCBehavior_LookAt(obj.GetMainLookAtPoint(), false)
                ));
 }
 public void StopAllNPCAction()
 {
     foreach (GameObject NPCObject in EntityManager.getObjectsOfType <NPCComponent>())
     {
         NPCComponent[] npcComps = NPCObject.GetComponents <NPCComponent> ();
         foreach (NPCComponent npcComp in npcComps)
         {
             npcComp.stop();
         }
     }
 }
 void Start()
 {
     // instantiate, then initialize all NPCs
     for (int i = 0; i < NPCCount; i++)
     {
         // instantiate GameObject
         NPCObject NPC = Object.Instantiate(NPCPrefab, Vector3.zero, Quaternion.identity).GetComponent <NPCObject> ();
         // call initialize function on NPCObject
         NPC.Initialize(i, "NPC" + i, false);
     }
 }
Example #6
0
    public NPCObject GetInformation(int npcid)
    {
        foreach (NPCObject npc in DatabaseNPCs)
        {
            if (npc.m_NPCID == npcid)
            {
                LastLoadedID = npcid;
                return(npc);
            }
        }
        NPCObject obj = null;

        return(obj);
    }
Example #7
0
    override public GameObject Spawn(Map map, Vector2 location)
    {
        GameObject      npc             = base.Spawn(map, location);
        StateController stateController = npc.AddComponent <StateController>();

        stateController.currentState = this.initialState;
        stateController.map          = map;
        NPCObject obj = new NPCObject(npc, maxHealth);

        obj.entityDropGen = entityDropGen;
        this.entityObject = obj;
        npc.GetComponent <EntityHealthManager>().entityObj = obj;
        return(npc);
    }
Example #8
0
    public bool GetNPCObject(int npcID, out NPCObject npcObject)
    {
        npcObject = null;

        foreach (NPCObject accessoryObj in _accessoryDict.Values)
        {
            if (accessoryObj.NPCID == npcID)
            {
                npcObject = accessoryObj;
                return(true);
            }
        }

        return(false);
    }
Example #9
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Debug.Log("exit");
            Application.Quit();
        }
        if (unlockUpdate)
        {
            foreach (GameObject go in activ_list)
            {
                ActivityObject ao = go.GetComponent <ActivityObject>();

                if (ao.getNeed() == activities.social)
                {
                    go.gameObject.transform.position = ao.getLocation();
                    //go.gameObject.transform.Translate( ao.getLocation(),Space.World);

                    NPCObject npc_temp = go.GetComponent <NPCObject>();

                    dict[go].material.SetColor("_Color", npc_temp.getStatusColor());
                    if (npc_temp.getCurrentIdleStats() == idle.searching)
                    {
                        ao.invokeStatusMassage("(" + ao.getX() + "," + ao.getY() + ")");
                    }
                    else
                    {
                        ao.invokeStatusMassage(npc_temp.getOccupiedActivity() + "");
                    }
                }
                else
                {
                    if (ao.getStatus())
                    {
                        ao.invokeStatusMassage("Occupied");
                        dict[go].material.SetColor("_Color", Color.red);
                    }
                    else
                    {
                        ao.invokeStatusMassage("avilable");
                        dict[go].material.SetColor("_Color", Color.green);
                    }
                }
            }
            unlockUpdate = false;
        }
    }
Example #10
0
    public static void closeSession()
    {
        delta            = 0f;
        inSession        = false;
        sessionCloseTime = Time.timeSinceLevelLoad;
        Debug.Log("Session end time: " + sessionCloseTime);

        foreach (GameObject NPCObject in EntityManager.getObjectsOfType <NPCComponent>())
        {
            NPCComponent[] npcComps = NPCObject.GetComponents <NPCComponent> ();
            foreach (NPCComponent npcComp in npcComps)
            {
                npcComp.setTimeProbability(90f);
                npcComp.stop();
            }
        }
    }
Example #11
0
        public PublicEvent(PublicEventInfo info, Map map)
        {
            Info = info;
            Map  = map;

            var splittedCoords = info.MultipleCoords.Split(',');

            foreach (var coord in splittedCoords)
            {
                var secondSplit = coord.Split(':');

                int x = 0; int y = 0;
                if (!int.TryParse(secondSplit[0], out x))
                {
                    return;
                }
                if (!int.TryParse(secondSplit[1], out y))
                {
                    return;
                }

                Locations.Add(new Point(x, y));


                string fileName          = string.Format("{0}-Event-{1}.txt", map.Info.FileName, info.Index);
                string directoryFileName = Path.Combine(Settings.EventsPath, fileName);

                if (!Directory.Exists(Settings.EventsPath))
                {
                    Directory.CreateDirectory(Settings.EventsPath);
                }

                if (!File.Exists(directoryFileName))
                {
                    FileStream NewFile = File.Create(directoryFileName);
                    NewFile.Close();
                }

                DefaultNPC = new NPCObject(new NPCInfo()
                {
                    Name = "DefaultNPC", FileName = fileName, IsDefault = true
                });
            }
        }
    // FixedUpdate is called once per frame
    protected virtual void FixedUpdate()
    {
        EntityManager.Start();

        if (EventManager.inSession)
        {
            foreach (GameObject NPCObject in EntityManager.getObjectsOfType <NPCComponent>())
            {
                NPCComponent[] npcComps = NPCObject.GetComponents <NPCComponent> ();
                foreach (NPCComponent npcComp in npcComps)
                {
                    StartCoroutine(npcComp.NPCAction());
                }
            }
        }
        else
        {
            GetComponent <EventManager> ().RepeatEvents();
        }
    }
Example #13
0
    public void ControllerUISetup()
    {
        foreach (GameObject NPCObject in EntityManager.getObjectsOfType <NPCComponent>())
        {
            GameObject _newList = Instantiate(npcComponentListPrefab);
            _newList.transform.position = Vector3.zero;
            _newList.transform.rotation = Quaternion.identity;
            _newList.transform.SetParent(compListParent);

            NPCComponent[] npcComps = NPCObject.GetComponents <NPCComponent> ();
            compListItemParent = _newList.transform.GetChild(0).GetChild(0).gameObject;
            GameObject _nameObj = Instantiate(npcGameObjectName);
            _nameObj.GetComponent <Text> ().text = NPCObject.name;
            _nameObj.transform.SetParent(compListItemParent.transform);
            foreach (NPCComponent npcComp in npcComps)
            {
                GameObject _newListItem = Instantiate(componentListItemPrefab);
                _newListItem.transform.SetParent(compListItemParent.transform);
                _newListItem.GetComponent <ComponentListItem> ().Setup(npcComp);
            }
        }
    }
Example #14
0
    public override bool Load(SecurityElement element)
    {
        if (element.Tag != "Items")
        {
            return(false);
        }

        if (element.Children != null)
        {
            foreach (SecurityElement childrenElement in element.Children)
            {
                NPCObject accessoryObject = new NPCObject();
                accessoryObject.Load(childrenElement);

                if (!_accessoryDict.ContainsKey(accessoryObject.NPCID))
                {
                    _accessoryDict[accessoryObject.NPCID] = accessoryObject;
                }
            }
            return(true);
        }
        return(false);
    }
Example #15
0
    private IEnumerator FadeContextMenu(bool fadeIn, NPCObject obj = null)
    {
        InteractionsPanel.SetActive(fadeIn);
        float alpha = fadeIn ? 0f : 1f;

        if (fadeIn)
        {
            SetContextMenuEnabled(true);
            while (alpha < 0.9f)
            {
                InteractionsPanel.transform.position = Camera.main.WorldToScreenPoint(g_FocusedObject.GetPosition());
                foreach (Image go in InteractionsPanel.GetComponents <Image>())
                {
                    Color c = go.color;
                    c.a     += 0.05f;
                    alpha    = c.a;
                    go.color = c;
                }
                yield return(null);
            }
        }
        else
        {
            while (alpha > 0f)
            {
                foreach (Image go in InteractionsPanel.GetComponents <Image>())
                {
                    Color c = go.color;
                    c.a     -= 0.05f;
                    alpha    = c.a;
                    go.color = c;
                }
                yield return(null);
            }
            SetContextMenuEnabled(false);
        }
    }
        public static NPCObject[] getGameObjectSeedDataJarvis()
        {
            NPCObject[] NPCO = new NPCObject[5];
            NPCO[0]      = new NPCObject();
            NPCO[0].PV.x = 100;
            NPCO[0].PV.y = 100;

            NPCO[1]      = new NPCObject();
            NPCO[1].PV.x = 101;
            NPCO[1].PV.y = 300;

            NPCO[2]      = new NPCObject();
            NPCO[2].PV.x = 200;
            NPCO[2].PV.y = 100;

            NPCO[3]      = new NPCObject();
            NPCO[3].PV.x = 201;
            NPCO[3].PV.y = 300;

            NPCO[4]      = new NPCObject();
            NPCO[4].PV.x = 150;
            NPCO[4].PV.y = 200;
            return(NPCO);
        }
Example #17
0
        private void MiniMap_BeforeDraw(object sender, EventArgs e)
        {
            foreach (var icon in QuestIcons)
            {
                icon.Dispose();
            }

            QuestIcons.Clear();

            MapControl map = GameScene.Scene.MapControl;

            if (map == null)
            {
                return;
            }

            if (map.MiniMap == 0 && Index != 2091)
            {
                SetSmallMode();
            }
            else if (map.MiniMap > 0 && _bigMode && Index == 2091)
            {
                SetBigMode();
            }

            if (map.MiniMap <= 0 || Index != 2090 || Libraries.MiniMap == null)
            {
                return;
            }

            Rectangle viewRect     = new Rectangle(0, 0, 120, 108);
            Point     drawLocation = Location;

            drawLocation.Offset(3, 22);

            Size  miniMapSize = Libraries.MiniMap.GetSize(map.MiniMap);
            float scaleX      = miniMapSize.Width / (float)map.Width;
            float scaleY      = miniMapSize.Height / (float)map.Height;

            viewRect.Location = new Point(
                (int)(scaleX * MapObject.User.CurrentLocation.X) - viewRect.Width / 2,
                (int)(scaleY * MapObject.User.CurrentLocation.Y) - viewRect.Height / 2);

            //   viewRect.Location = viewRect.Location.Subtract(1, 1);
            if (viewRect.Right >= miniMapSize.Width)
            {
                viewRect.X = miniMapSize.Width - viewRect.Width;
            }
            if (viewRect.Bottom >= miniMapSize.Height)
            {
                viewRect.Y = miniMapSize.Height - viewRect.Height;
            }

            if (viewRect.X < 0)
            {
                viewRect.X = 0;
            }
            if (viewRect.Y < 0)
            {
                viewRect.Y = 0;
            }

            Libraries.MiniMap.Draw(map.MiniMap, viewRect, drawLocation, Color.FromArgb(255, 255, 255), _fade);


            int startPointX = (int)(viewRect.X / scaleX);
            int startPointY = (int)(viewRect.Y / scaleY);

            for (int i = MapControl.Objects.Count - 1; i >= 0; i--)
            {
                MapObject ob = MapControl.Objects[i];

                if (ob.Race == ObjectType.Item || ob.Dead || ob.Race == ObjectType.Spell || ob.Sneaking)
                {
                    continue;
                }
                float x = ((ob.CurrentLocation.X - startPointX) * scaleX) + drawLocation.X;
                float y = ((ob.CurrentLocation.Y - startPointY) * scaleY) + drawLocation.Y;

                Color colour;

                if ((GroupDialog.GroupList.Contains(ob.Name) && MapObject.User != ob) || ob.Name.EndsWith(string.Format("({0})", MapObject.User.Name)))
                {
                    colour = Color.FromArgb(0, 0, 255);
                }
                else
                if (ob is PlayerObject)
                {
                    colour = Color.FromArgb(255, 255, 255);
                }
                else if (ob is NPCObject || ob.AI == 6)
                {
                    colour = Color.FromArgb(0, 255, 50);
                }
                else
                {
                    colour = Color.FromArgb(255, 0, 0);
                }

                DXManager.Sprite.Draw2D(DXManager.RadarTexture, Point.Empty, 0, new PointF((int)(x - 0.5F), (int)(y - 0.5F)), colour);

                #region NPC Quest Icons

                NPCObject npc = ob as NPCObject;
                if (npc != null && npc.GetAvailableQuests(true).Any())
                {
                    string text  = "";
                    Color  color = Color.Empty;

                    switch (npc.QuestIcon)
                    {
                    case QuestIcon.ExclamationBlue:
                        color = Color.DodgerBlue;
                        text  = "!";
                        break;

                    case QuestIcon.ExclamationYellow:
                        color = Color.Yellow;
                        text  = "!";
                        break;

                    case QuestIcon.ExclamationGreen:
                        color = Color.Green;
                        text  = "!";
                        break;

                    case QuestIcon.QuestionBlue:
                        color = Color.DodgerBlue;
                        text  = "?";
                        break;

                    case QuestIcon.QuestionWhite:
                        color = Color.White;
                        text  = "?";
                        break;

                    case QuestIcon.QuestionYellow:
                        color = Color.Yellow;
                        text  = "?";
                        break;

                    case QuestIcon.QuestionGreen:
                        color = Color.Green;
                        text  = "?";
                        break;
                    }

                    QuestIcons.Add(new MirLabel
                    {
                        AutoSize   = true,
                        Parent     = GameScene.Scene.MiniMapDialog,
                        Font       = new Font(Settings.FontName, 9f, FontStyle.Bold),
                        DrawFormat = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter,
                        Text       = text,
                        ForeColour = color,
                        Location   = new Point((int)(x - Settings.ScreenWidth + GameScene.Scene.MiniMapDialog.Size.Width) - 6, (int)(y) - 10),
                        NotControl = true,
                        Visible    = true,
                        Modal      = true
                    });
                }

                #endregion
            }
        }
Example #18
0
    void Update()
    {
        if (shopController.IsShopWindowOpen())
        {
            Debug.Log("ShopControllerIsActive");
            if (Inventory.UseShopInventoryControls())
            {
                return;
            }
        }

        if (SelectedItemImage.gameObject.activeSelf)
        {
            SelectedItemImage.transform.position = Input.mousePosition;
            SelectedItemImage.transform.SetAsLastSibling();
        }

        MouseObject = GetMouseObject();

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            if (Time.time > PickUpTime)
            {
                PickUpTime = Time.time + 0.2f;
                Network.Enqueue(new C.PickUp());
            }
        }

        if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
        {
            if (Input.GetMouseButton(0))
            {
                if (!eventSystem.IsPointerOverGameObject() && CanAttack())
                {
                    GameManager.InputDelay = Time.time + 0.5f;
                    NextHitTime            = Time.time + 1.6f;
                    QueuedAction           = new QueuedAction {
                        Action = MirAction.Attack, Direction = GameManager.MouseUpdate(), Location = User.Player.CurrentLocation
                    };
                }
                return;
            }
            else if (TargetObject != null && !(TargetObject is MonsterObject) && !TargetObject.Dead && TargetObject.gameObject.activeSelf && CanAttack())
            {
                Point self = new Point(User.Player.CurrentLocation.x, User.Player.CurrentLocation.y);
                Point targ = new Point(TargetObject.CurrentLocation.x, TargetObject.CurrentLocation.y);
                if (Functions.InRange(self, targ, 1))
                {
                    NextHitTime = Time.time + 1.6f;
                    MirDirection direction = Functions.DirectionFromPoint(self, targ);
                    QueuedAction = new QueuedAction {
                        Action = MirAction.Attack, Direction = direction, Location = User.Player.CurrentLocation
                    };
                    return;
                }

                MirDirection targetdirection = Functions.DirectionFromPoint(self, targ);

                if (!CanWalk(targetdirection))
                {
                    return;
                }

                QueuedAction = new QueuedAction {
                    Action = MirAction.Walking, Direction = targetdirection, Location = ClientFunctions.VectorMove(User.Player.CurrentLocation, targetdirection, 1)
                };
            }
        }

        if (Input.GetMouseButtonUp(0) && !eventSystem.IsPointerOverGameObject() && Time.time > GameManager.InputDelay)
        {
            if (SelectedCell != null)
            {
                SelectedItemImage.gameObject.SetActive(false);

                MessageBox.Show($"Drop {SelectedCell.Item.Name}?", okbutton: true, cancelbutton: true);
                MessageBox.OK += () =>
                {
                    Network.Enqueue(new C.DropItem {
                        UniqueID = SelectedCell.Item.UniqueID, Count = 1
                    });
                    SelectedCell.Locked = true;
                    SelectedCell        = null;
                };
                MessageBox.Cancel += () =>
                {
                    Debug.Log("CancelInvoke");
                    SelectedCell = null;
                };
                return;
            }
        }

        if (Input.GetMouseButton(0) && SelectedCell == null && !eventSystem.IsPointerOverGameObject() && Time.time > GameManager.InputDelay)
        {
            GameManager.User.CanRun = false;

            if (MouseObject != null)
            {
                switch (MouseObject.gameObject.layer)
                {
                case 9:     //Monster
                    MonsterObject monster = (MonsterObject)MouseObject;
                    if (monster.Dead)
                    {
                        break;
                    }
                    TargetObject           = monster;
                    GameManager.InputDelay = Time.time + 0.5f;
                    return;

                case 10:     //NPC
                    NPCObject npc = (NPCObject)MouseObject;
                    NPCName = npc.Name;
                    NPCID   = npc.ObjectID;
                    NPCCamera.transform.SetParent(npc.CameraLocation.transform, false);
                    Network.Enqueue(new C.CallNPC {
                        ObjectID = npc.ObjectID, Key = "[@Main]"
                    });
                    GameManager.InputDelay = Time.time + 0.5f;
                    return;
                }
            }

            TargetObject = null;
            GameManager.CheckMouseInput();
        }
        else if (Input.GetMouseButton(1) && !eventSystem.IsPointerOverGameObject())
        {
            GameManager.CheckMouseInput();
        }
        else
        {
            GameManager.User.CanRun = false;
            if (TargetObject != null && TargetObject is MonsterObject && !TargetObject.Dead && TargetObject.gameObject.activeSelf && CanAttack())
            {
                Point self = new Point(User.Player.CurrentLocation.x, User.Player.CurrentLocation.y);
                Point targ = new Point(TargetObject.CurrentLocation.x, TargetObject.CurrentLocation.y);
                if (Functions.InRange(self, targ, 1))
                {
                    NextHitTime = Time.time + 1.6f;
                    MirDirection direction = Functions.DirectionFromPoint(self, targ);
                    QueuedAction = new QueuedAction {
                        Action = MirAction.Attack, Direction = direction, Location = User.Player.CurrentLocation
                    };
                    return;
                }

                MirDirection targetdirection = Functions.DirectionFromPoint(self, targ);

                if (!CanWalk(targetdirection))
                {
                    return;
                }

                QueuedAction = new QueuedAction {
                    Action = MirAction.Walking, Direction = targetdirection, Location = ClientFunctions.VectorMove(User.Player.CurrentLocation, targetdirection, 1)
                };
            }
        }
    }
Example #19
0
    private void UpdateThirdPersonInput()
    {
        foreach (THIRD_PERSON_MOUSE_INPUT mi in Enum.GetValues(typeof(THIRD_PERSON_MOUSE_INPUT)))
        {
            if (Input.GetKeyUp((KeyCode)mi))
            {
                switch (mi)
                {
                case THIRD_PERSON_MOUSE_INPUT.INTERACT:
                    RaycastHit2D hit = Physics2D.Raycast(Input.mousePosition, Vector3.zero);
                    if (hit.collider != null)
                    {
                        if (g_InteractionsMap.ContainsKey(hit.collider.gameObject))
                        {
                            string tag = g_InteractionsMap[hit.collider.gameObject].Tag;
                            switch (tag)
                            {
                            case Interaction_Grab:
                                g_BehaviorAgent.StartEvent(g_BehaviorAgent.NPCBehavior_Grab(g_FocusedObject), true);
                                break;

                            case Interaction_Consume:
                                break;

                            case Interaction_Sit:
                                g_BehaviorAgent.StartEvent(g_BehaviorAgent.NPCBehavior_TakeSit(g_FocusedObject), true);
                                break;

                            default:
                                Debug.Log("No Interaction Tag: " + hit.transform.gameObject + " for object: " + g_FocusedObject);
                                break;
                            }
                        }
                    }
                    break;
                }
            }
            else if (Input.GetKey((KeyCode)mi))
            {
                switch (mi)
                {
                case THIRD_PERSON_MOUSE_INPUT.WALK_TO:
                    RaycastHit locationHit;
                    if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out locationHit, 100.0f))
                    {
                        g_NPCController.Body.GoTo(locationHit.point);
                    }
                    break;

                case THIRD_PERSON_MOUSE_INPUT.FLOAT_CAMERA:
                    if (EnableMouseCameraRotation)
                    {
                        float horChange = Input.mousePosition.x - g_MouseLastPosition.x;
                        float verChange = Input.mousePosition.y - g_MouseLastPosition.y;
                        bool  correct   = false;
                        if (Mathf.Abs(horChange) > CameraRotationThreshold)
                        {
                            int mod = horChange > 0 ? 1 : -1;
                            g_Camera.RotateAround(g_NPCController.GetPosition(), mod * Vector3.up, CameraRotationSpeed * Time.deltaTime);
                            correct = true;
                        }
                        if (Mathf.Abs(verChange) > CameraRotationThreshold)
                        {
                            int     mod          = verChange > 0 ? -1 : 1;
                            Vector3 rotationAxis =
                                Vector3.Cross(
                                    g_Camera.forward,
                                    Vector3.up);
                            g_Camera.RotateAround(g_NPCController.GetPosition(), rotationAxis, mod * CameraRotationSpeed * Time.deltaTime);
                            correct = true;
                        }
                        if (correct)
                        {
                            CameraOffset = Camera.main.transform.position - g_NPCController.GetTransform().position;
                        }
                    }
                    break;

                case THIRD_PERSON_MOUSE_INPUT.INTERACT:
                    if (!g_ObjectFocused)
                    {
                        RaycastHit hit;
                        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                        if (Physics.Raycast(ray, out hit, 100.0f))
                        {
                            NPCObject npcObject = hit.transform.GetComponent <NPCObject>();
                            if (npcObject != null)
                            {
                                g_FocusedObject = npcObject;
                                g_ObjectFocused = true;
                                g_NPCController.Body.StartLookAt(npcObject.GetTransform());
                                StartCoroutine(FadeContextMenu(true, g_FocusedObject));
                            }
                        }
                    }
                    break;
                }
                g_MouseLastPosition = Input.mousePosition;
            }
        }

        foreach (THIRD_PERSON_KEYBOARD_INPUT key in Enum.GetValues(typeof(THIRD_PERSON_KEYBOARD_INPUT)))
        {
            if (Input.GetKey((KeyCode)key))
            {
                switch (key)
                {
                case THIRD_PERSON_KEYBOARD_INPUT.FORWARD:
                    g_NPCController.Body.Move(LOCO_STATE.FORWARD);
                    break;

                case THIRD_PERSON_KEYBOARD_INPUT.BACKWARDS:
                    g_NPCController.Body.Move(LOCO_STATE.BACKWARDS);
                    break;

                case THIRD_PERSON_KEYBOARD_INPUT.CAM_ROT_LEFT:
                    RotateCameraLeft();
                    break;

                case THIRD_PERSON_KEYBOARD_INPUT.CAM_ROT_RIGHT:
                    RotateCameraRight();
                    break;

                case THIRD_PERSON_KEYBOARD_INPUT.TURN_LEFT:
                    g_NPCController.Body.Move(LOCO_STATE.LEFT);
                    RotateCameraRight(0.5f);
                    break;

                case THIRD_PERSON_KEYBOARD_INPUT.TURN_RIGHT:
                    g_NPCController.Body.Move(LOCO_STATE.RIGHT);
                    RotateCameraLeft(0.5f);
                    break;

                case THIRD_PERSON_KEYBOARD_INPUT.RUN:
                    g_NPCController.Body.Move(LOCO_STATE.RUN);
                    break;
                }
            }
            else if (Input.GetKeyUp((KeyCode)key))
            {
                switch (key)
                {
                case THIRD_PERSON_KEYBOARD_INPUT.JUMP:
                    g_NPCController.Body.Move(LOCO_STATE.JUMP);
                    break;

                case THIRD_PERSON_KEYBOARD_INPUT.TOGGLE_WALK:
                    g_NPCController.Body.Move(LOCO_STATE.TOGGLE_WALK);
                    break;

                case THIRD_PERSON_KEYBOARD_INPUT.TOGGLE_ACTION:
                    g_NPCController.Body.ToggleAction();
                    break;
                }
            }
        }
    }
Example #20
0
    public Node NPCBehavior_TakeSit(NPCObject chair)
    {
        Transform t = chair.MainInteractionPoint;

        return(NPCBehavior_TakeSit(t));
    }
Example #21
0
        // Merges two subarrays of arr[].
        // First subarray is arr[l..m]
        // Second subarray is arr[m+1..r]
        public void merge(NPCObject[] arr, int l, int m, int r)
        {
            // Find sizes of two subarrays to be merged
            int n1 = m - l + 1;
            int n2 = r - m;

            /* Create temp arrays - Will need to match the objects comparing */
            NPCObject[] L = new NPCObject[n1];
            NPCObject[] R = new NPCObject[n2];

            /*Copy data to temp arrays*/
            int i;

            for (i = 0; i < n1; ++i)
            {
                L[i] = arr[l + i];
            }
            int j;

            for (j = 0; j < n2; ++j)
            {
                R[j] = arr[m + 1 + j];
            }

            /* Merge the temp arrays */

            // Initial indexes of first and second subarrays
            i = 0;
            j = 0;

            // Initial index of merged subarray array
            int k = l;

            while (i < n1 && j < n2)
            {
                // The only code that actually compares itself
                // Can change this one line to meet the needs of the comparators.
                if (L[i].PV.x <= R[j].PV.x)
                {
                    arr[k] = L[i];
                    i++;
                }
                else
                {
                    arr[k] = R[j];
                    j++;
                }
                k++;
            }

            /* Copy remaining elements of L[] if any */
            while (i < n1)
            {
                arr[k] = L[i];
                i++;
                k++;
            }

            /* Copy remaining elements of R[] if any */
            while (j < n2)
            {
                arr[k] = R[j];
                j++;
                k++;
            }
        }
Example #22
0
 private RunStatus Behavior_GrabRightHand(NPCObject t, bool grab = true)
 {
     g_NPCController.Body.GrabRightHand(t, grab);
     return(RunStatus.Success);
 }
Example #23
0
    private void initTheActivities()
    {
        activ_list = new ArrayList();

        int i, j;

        foreach (GameObject go in GameObject.FindGameObjectsWithTag("fun"))
        {
            Debug.Log("fun");
            ActivityObject ob = go.GetComponent <ActivityObject>();
            ob.setNeed(activities.fun);
            i = Random.Range(2, layout.getSize() - 2);
            j = Random.Range(2, layout.getSize() - 2);
            while (physicalMap.getpathMapValue(i, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j - 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j - 1) is house.wall)
            {
                i = Random.Range(2, layout.getSize() - 2);
                j = Random.Range(2, layout.getSize() - 2);
            }
            worldMap[i, j] = house.unavailable_floor;
            ob.setMapLocation(i, j, size);

            ob.setUpdateable();

            go.gameObject.transform.position = ob.getLocation();
            dict.Add(go, go.GetComponentInChildren <Renderer>());
            activ_list.Add(go);
        }
        //set the entrences objects



        foreach (GameObject go in GameObject.FindGameObjectsWithTag("bladder"))
        {
            Debug.Log("bladder");
            ActivityObject ob = go.GetComponent <ActivityObject>();
            ob.setNeed(activities.bladder);
            i = Random.Range(2, layout.getSize() - 2);
            j = Random.Range(2, layout.getSize() - 2);
            while (physicalMap.getpathMapValue(i, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j - 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j - 1) is house.wall
                   )
            {
                i = Random.Range(2, layout.getSize() - 2);
                j = Random.Range(2, layout.getSize() - 2);
            }
            worldMap[i, j] = house.unavailable_floor;
            ob.setMapLocation(i, j, size);

            ob.setUpdateable();
            go.gameObject.transform.position = ob.getLocation();
            dict.Add(go, go.GetComponentInChildren <Renderer>());
            activ_list.Add(go);
        }

        foreach (GameObject go in GameObject.FindGameObjectsWithTag("hunger"))
        {
            Debug.Log("hunger");
            ActivityObject ob = go.GetComponent <ActivityObject>();
            ob.setNeed(activities.hunger);
            i = Random.Range(2, layout.getSize() - 2);
            j = Random.Range(2, layout.getSize() - 2);
            while (physicalMap.getpathMapValue(i, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j - 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j - 1) is house.wall)
            {
                i = Random.Range(2, layout.getSize() - 2);
                j = Random.Range(2, layout.getSize() - 2);
            }
            worldMap[i, j] = house.unavailable_floor;
            ob.setMapLocation(i, j, size);

            ob.setUpdateable();
            go.gameObject.transform.position = ob.getLocation();
            dict.Add(go, go.GetComponentInChildren <Renderer>());
            activ_list.Add(go);
        }

        foreach (GameObject go in GameObject.FindGameObjectsWithTag("hygiene"))
        {
            Debug.Log("hygiene");
            ActivityObject ob = go.GetComponent <ActivityObject>();
            ob.setNeed(activities.hygiene);
            i = Random.Range(2, layout.getSize() - 2);
            j = Random.Range(2, layout.getSize() - 2);
            while (physicalMap.getpathMapValue(i, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j - 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j - 1) is house.wall)
            {
                i = Random.Range(2, layout.getSize() - 2);
                j = Random.Range(2, layout.getSize() - 2);
            }
            worldMap[i, j] = house.unavailable_floor;
            ob.setMapLocation(i, j, size);

            ob.setUpdateable();
            go.gameObject.transform.position = ob.getLocation();
            dict.Add(go, go.GetComponentInChildren <Renderer>());
            activ_list.Add(go);
        }

        foreach (GameObject go in GameObject.FindGameObjectsWithTag("energy"))
        {
            Debug.Log("energy");
            ActivityObject ob = go.GetComponent <ActivityObject>();
            ob.setNeed(activities.energy);
            i = Random.Range(2, layout.getSize() - 2);
            j = Random.Range(2, layout.getSize() - 2);
            while (physicalMap.getpathMapValue(i, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j - 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j - 1) is house.wall)
            {
                i = Random.Range(2, layout.getSize() - 2);
                j = Random.Range(2, layout.getSize() - 2);
            }
            worldMap[i, j] = house.unavailable_floor;
            ob.setMapLocation(i, j, size);

            ob.setUpdateable();
            go.gameObject.transform.position = ob.getLocation();
            dict.Add(go, go.GetComponentInChildren <Renderer>());
            activ_list.Add(go);
        }

        foreach (GameObject go in GameObject.FindGameObjectsWithTag("social"))
        {
            Debug.Log("social");
            ActivityObject ob = go.GetComponent <ActivityObject>();
            ob.setNeed(activities.social);
            i = Random.Range(2, layout.getSize() - 2);
            j = Random.Range(2, layout.getSize() - 2);
            while (physicalMap.getpathMapValue(i, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i + 1, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j + 1) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j) is house.wall ||
                   physicalMap.getpathMapValue(i - 1, j - 1) is house.wall ||
                   physicalMap.getpathMapValue(i, j - 1) is house.wall)
            {
                i = Random.Range(2, layout.getSize() - 2);
                j = Random.Range(2, layout.getSize() - 2);
            }
            worldMap[i, j] = house.unavailable_floor;
            ob.setMapLocation(i, j, size);

            NPCObject npc = go.GetComponent <NPCObject>();



            ob.setUpdateable();


            go.gameObject.transform.position = ob.getLocation();
            dict.Add(go, go.GetComponentInChildren <Renderer>());
            activ_list.Add(go);
        }

        Debug.Log("all activities" + activ_list.Count);
    }
 public DblLinkedList(NPCObject npc)
 {
     NPC = npc;
 }