Наследование: MonoBehaviour
Пример #1
0
 private void Start()
 {
     //manager = FindObjectOfType<BigDialogueManager>();
     //nm = FindObjectOfType<NameManager>();
     npc = gameObject.GetComponent <NPCScript>();
     id  = npc.GetID();
 }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        Player = GameObject.Find("Player");

        NPC  = GameObject.Find("NPC");
        NPCS = NPC.GetComponent <NPCScript>();
    }
Пример #3
0
    //callback
    public void ProceedToTalk(bool talk)
    {
        talkOrNotCanvas.SetActive(false);
        if (!talk)
        {
            GameControl.gameState = (int)GameControl.GameState.PlayerNavigating;
            return;
        }
        if (playerRaycastHitObj == null)
        {
            Debug.Log("npc null");
            return;
        }
        NPCScript npc = playerRaycastHitObj.GetComponent <NPCScript>();

        if (npc == null)
        {
            return;
        }

        GameControl.gameState = (int)GameControl.GameState.HumanInteraction;
        EnableMouseLook(false);

        DialogueSystem.dialogueSystem.StartInteraction(npc);
    }
Пример #4
0
    public IEnumerable TalkDuncan(WorldClient c, NPCScript n)
    {
        if (QuestActive(c, this.Id))
        {
            FinishQuestObjective(c, this.Id, "talk_duncan");

            n.Msg(c, Options.Name, "(You hand Nao's Letter of Introduction to Duncan.)");
            n.Msg(c, "Ah, a letter from Nao.<br/>Hard to believe that little<br/>tomboy's all grown up...");
            n.Msg(c, Options.Name, "(Duncan folds the letter in half and puts it in his pocket.)");
            n.Msg(c, "So, you're <username/>.<br/>I'm Duncan, the chief of this town.<br/>Welcome to Tir Chonaill.");
            n.Msg(c, "Would you like to learn how to complete quests?");
            n.Msg(c, n.Image("npctalk_questwindow", true, 272, 235), n.Text("Press the "), n.Hotkey("QuestView"), n.Text(" key or<br/>press the Quest button at the bottom of your screen.<br>The quest window will appear and display your current quests."));

            while (true)
            {
                n.Msg(c, n.Text("Press the "), n.Hotkey("QuestView"), n.Text(" key or<br/>press the Quest button at the bottom of your screen."), n.Button("I pressed the Quest button", "@pressed"), n.Button("$hidden", "@quest_btn_clicked", "autoclick_QuestView"));
                var r = n.Select(c);
                if (r != "@pressed")
                    break;
                n.Msg(c, "Hmm... Are you sure you pressed the Quest button?<br/>It's possible that the Quest Window was already open, so<br/>try pressing it again.");
            }

            n.Msg(c, "Well done. See the list of quests?<br/>Clicking on a quest brings up the quest's details.<br/>Quests will show a yellow Complete button<br/>next to their names when you finish them.");
            n.Msg(c, "Try pressing the Complete button now.<br/>As important as it is to complete quests,<br/>it's just as important to press the \"Complete\" button<br/>afterwards to recieve your rewards.");
            n.Msg(c, "(Duncan looks at you with his benevolent hazel eyes.)");
            n.Msg(c, "You've just learned one very basic skill<br/>to survive in Erinn.");
            n.Msg(c, "Soon, you will recieve a quest from an owl.<br/>Then, you will be able to start your training for real.");

            Break();
        }

        End();
    }
Пример #5
0
    void Shoot()
    {
        timer = 0f;

        gunLight.enabled = true;
        gunLine.enabled  = true;
        AudioSource gunshot = GetComponent <AudioSource> ();

        gunshot.Play();

        gunLine.SetPosition(0, transform.position);
        shootRay.origin    = transform.position;
        shootRay.direction = transform.forward;

        if (Physics.Raycast(shootRay, out shootHit, range, shootableMask))
        {
            NPCScript enemyHealth = shootHit.collider.GetComponent <NPCScript>();
            Rigidbody enemyBody   = shootHit.collider.GetComponent <Rigidbody> ();


            enemyHealth.TakeDamage(shootHit.point);
            enemyHealth.ApplyForce(enemyBody, shootHit);
            countText.text = points.ToString();

            gunLine.SetPosition(1, shootHit.point);
        }
        else
        {
            gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range);
        }
    }
Пример #6
0
    void Start()
    {
        instance = this;

        animator       = GetComponent <Animator>();
        spriteRenderer = GetComponent <SpriteRenderer>();
        rb             = GetComponent <Rigidbody2D>();
        theDB          = DatabaseManager.instance;
        theDM          = DialogueManager.instance;

        que = new Queue <Transform>();    //이동할 위치
        // for(int i =0 ; i<moveLocation.Length;i++){

        //     que.Enqueue(moveLocation[i]);
        // }
        thePlayer = PlayerManager.instance;

        maxBound = JYDArea.bounds.max;
        minBound = JYDArea.bounds.min;
        // Debug.Log("1 "+maxBound.x);
        // Debug.Log("2 "+ (-maxBound.x));
        //Debug.Log("2 "+maxBound.y);
        // target = this.gameObject.transform;
        // target = thePlayer.gameObject.transform;
    }
Пример #7
0
        private void Awake()
        {
            deliveryCount = 0;
            thePlayer     = FindObjectOfType <PlayerController>();
            pickupParent  = FindObjectOfType <PickupParentScript>();
            theDoor       = FindObjectOfType <KioskDoor>();
            whereIs       = PlayerLocationState.InLobby;

            warpLocations = new List <GameObject>(GameObject.FindGameObjectsWithTag("PlayerWarpPoint"));

            kioskSolid   = FindObjectOfType <KioskEntranceSolidCollider>();
            kioskTrigger = FindObjectOfType <KioskEntranceTriggerCollider>();
            kioskRoof    = FindObjectOfType <KioskRoofScript>();

            npc = FindObjectOfType <NPCScript>();

            _paused = false;

            m_AudioSource      = GetComponent <AudioSource>();
            m_AudioSource.clip = delivery1;
            m_AudioSource.Play();
            m_AudioSource.loop = true;

            theEagleHasLandedOnTheRoof = false;

            done = false;

            pauseMenu = FindObjectOfType <PauseMenuScript>();
            dialogue  = FindObjectOfType <DialogueScript>();

            _inDialogue = false;
            dialogue.gameObject.SetActive(false);
            pauseMenu.gameObject.SetActive(false);
        }
Пример #8
0
    // Update is called once per frame
    void OnCollisionEnter(Collision col)
    {
        Vector3 enemyposition = enemy.transform.position;

        NPCScript enemyHealth = enemy.GetComponent <Collider>().GetComponent <NPCScript>();

        enemyHealth.TakeDamage(enemyposition);
    }
Пример #9
0
 public bool AddSelection(NPCScript n)
 {
     if (curCoroutine != GameCoroutineType.SlowSpeedUpdate)
     {
         return(false);
     }
     NPCSelectList.Add(n); return(true);
 }
Пример #10
0
 public void NameNewCharacter(NPCScript npc)
 {
     inputField.gameObject.SetActive(true);
     inputField.ActivateInputField();
     curNPC = npc;
     player.UnlockMouse();
     notes.typing = true;
     //npc.SetName(curString);
 }
Пример #11
0
 public void StartInteraction(NPCScript npc)
 {
     //enable diaglogue canvas
     //set init text
     dialogueState = (int)DialogueState.Greeting;
     diaglogueCanvas.SetActive(true);
     //StartCoroutine(Interaction(NPCtemper, NPCbeggedToday));
     StartCoroutine(Interaction(npc));
 }
Пример #12
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        PlayerScript bird = (collision.collider.GetComponent <PlayerScript>());

        if (bird != null && bird._launched)
        {
            Destroy(gameObject);
        }

        NPCScript enemy = collision.collider.GetComponent <NPCScript>();
    }
Пример #13
0
    public void StartDialog(NPCScript npcScript)
    {
        int dialogID = npcScript.Npc.DialogID;
        SetCurrentDialog(dialogID);

        currentDialog.Start();

        CanvasGroup.alpha = 1;
        CanvasGroup.blocksRaycasts = true;
        CanvasGroup.interactable = true;
        IsOpen = true;
    }
Пример #14
0
    public void StartDialog(NPCScript npcScript)
    {
        int dialogID = npcScript.Npc.DialogID;

        SetCurrentDialog(dialogID);

        currentDialog.Start();

        CanvasGroup.alpha          = 1;
        CanvasGroup.blocksRaycasts = true;
        CanvasGroup.interactable   = true;
        IsOpen = true;
    }
Пример #15
0
    void Update()
    {
        GameObject closest  = null;
        float      distance = Mathf.Infinity;
        Vector3    position = transform.position;

        foreach (GameObject target in targets)
        {
            if (target != null)
            {
                Vector3 diff        = target.transform.position - position;
                float   curDistance = diff.sqrMagnitude;
                if (curDistance < distance)
                {
                    closest  = target;
                    distance = curDistance;
                    enemy    = closest.transform;
                }
            }
        }

        FollowPlayer follow        = GetComponent <FollowPlayer> ();
        Vector3      enemyposition = enemy.transform.position;

        //if G in clicked attack enemies within distance
        if (Input.GetKey(KeyCode.G))
        {
            if (enemy)
            {
                follow.isFollowing = false;
                Vector3 offset = enemy.position - myTransform.position;
                float   sqrLen = offset.sqrMagnitude;
                if (sqrLen < closeDistance * closeDistance)
                {
                    myTransform.LookAt(enemy);
                    anim.SetBool("attack", true);
                    NPCScript enemyHealth = enemy.GetComponent <Collider>().GetComponent <NPCScript>();
                    if (enemyHealth != null)
                    {
                        enemyHealth.TakeDamage(enemyposition);
                    }
                }
                else
                {
                    anim.SetBool("attack", false);
                    myTransform.Translate(Vector3.forward * 8 * Time.deltaTime);
                    myTransform.LookAt(enemy);
                }
            }
        }
    }
Пример #16
0
    [SerializeField] private float fleeRange = 4f; // The range away from the opponent for it to start fleeing.

    public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (PhotonNetwork.isMasterClient && NPCScript.Target != null)
        {
            if (Vector3.Distance(NPCScript.Waypoint, NPCScript.Npc.transform.position) < NPCScript.NearWaypointRange || Vector3.Distance(NPCScript.Target.transform.position, NPCScript.Npc.transform.position) < fleeRange)
            {
                NPCScript.SetFleeWaypoint();
            }
            if (NPCScript.Agent.isOnNavMesh)
            {
                NPCScript.Agent.SetDestination(NPCScript.Waypoint);
            }
        }
    }
Пример #17
0
    // Update is called once per frame
    void Update()
    {
        Debug.Log("state: " + GameControl.gameState);
        if (disableMove)
        {
            return;
        }
        if (GameControl.gameState == (int)GameControl.GameState.PlayerNavigating)
        {
            Navigate();

            LookAtObject();

            if (playerRaycastHitObj != null)
            {
                //Debug.Log("hit: " + playerRaycastHitObj.name);
                if (playerRaycastHitObj.tag == "NPC" && playerRaycastHitObj.name == "NPC_rigged")
                {
                    //show a talk sign
                    //npc turn around, look at player
                    NPCScript npc = playerRaycastHitObj.GetComponent <NPCScript>();
                    if (!npc.beggedToday)
                    {
                        EnableMouseLook(false);
                        GameControl.gameState = (int)GameControl.GameState.BrowsingMenu;

                        //playerRaycastHitObj.transform.parent.gameObject.GetComponent<NavMeshAgent>().Stop();
                        playerRaycastHitObj.transform.parent.LookAt(gameObject.transform);
                        playerRaycastHitObj.GetComponent <Animation>().Stop();
                        playerRaycastHitObj.transform.parent.gameObject.GetComponent <NavMeshAgent>().enabled = false;
                        //Destroy(playerRaycastHitObj.GetComponent<Rigidbody>());
                        talkOrNotCanvas.SetActive(true);
                    }
                    else
                    {
                        playerRaycastHitObj = null;
                    }
                }
            }
        }
        else if (GameControl.gameState == (int)GameControl.GameState.HumanInteraction)
        {
            //check dialogue state
            Debug.Log("having conversation");
        }
        else if (GameControl.gameState == (int)GameControl.GameState.BrowsingMenu)
        {
            Debug.Log("BrowsingMenu");
        }
    }
Пример #18
0
 public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (PhotonNetwork.isMasterClient)
     {
         if (Vector3.Distance(NPCScript.Waypoint, NPCScript.Npc.transform.position) < NPCScript.NearWaypointRange || !NPCScript.Agent.hasPath)
         {
             NPCScript.SetRandomWaypoint();
         }
         if (NPCScript.Agent.isOnNavMesh)
         {
             NPCScript.Agent.SetDestination(NPCScript.Waypoint);
         }
     }
 }
Пример #19
0
    protected virtual void Start()
    {
        audioSources = GetComponents<AudioSource>();
        animator = GetComponent<Animator>();
		fearMeter = GameObject.Find ("FearMeter").GetComponent<Slider> ();

        npc = GameObject.Find("PlayerCollider").GetComponent<NPCScript>();
		npcAudio = GameObject.Find("PlayerCollider").GetComponent<PlayerAudio>();

        // determine what floor we are on using elevation markers.
        if      (transform.position.y > GameObject.Find("2").transform.position.y) floor = 2;
        else if (transform.position.y > GameObject.Find("1").transform.position.y) floor = 1;
        else if (transform.position.y > GameObject.Find("G").transform.position.y) floor = 0;
        else floor = -1;
    }
Пример #20
0
        public static void Process(NPCScript script)
        {
            if (NextCheck > Envir.Now)
            {
                return;
            }

            var matches = Robots.Where(x => x.IsMatch(Envir.Now));

            foreach (var match in matches)
            {
                script.Call(match.Page);
            }

            SetNextCheck();
        }
Пример #21
0
    //on collision enter
    // if others tag is item
    // carry = other
    //other. RB = disabled

    //if others tag is enemy
    // health -=1
    //send flying

    void findClosestNPC()
    {
        distanceToClosestNPC = Mathf.Infinity;
        NPCScript closestNPC = null;

        NPCScript[] allNPCs = GameObject.FindObjectsOfType <NPCScript>();

        foreach (NPCScript currentNPC in allNPCs)
        {
            float distanceToNPC = (currentNPC.transform.position - this.transform.position).sqrMagnitude;
            if (distanceToNPC < distanceToClosestNPC)
            {
                distanceToClosestNPC = distanceToNPC;
                closestNPC           = currentNPC;
                shootTarget          = closestNPC.transform;
            }
        }

        Debug.DrawLine(this.transform.position, closestNPC.transform.position);
    }
Пример #22
0
    private void OnTriggerStay(Collider other)
    {
        if (other.gameObject.tag == "Turnip" && !holdingTurnip)
        {
            canPickTurnip = true;
            activeTurnip  = other.gameObject;
        }

        if (other.gameObject.tag == "DialogueTrigger")
        {
            npc = other.gameObject.GetComponent <NPCScript>();
            if (Input.GetButtonDown("Fire1") && !dialogueManager.dialogueWindow.activeSelf)
            {
                other.gameObject.GetComponent <NPCScript>().dialogueIndicator.SetActive(false);
                dialogueManager.dialogueWindow.SetActive(true);
                npc.SetDialogue();
                canMove = false;
                cameraScript.DialogueCamera();
            }
        }
    }
Пример #23
0
    void Update()
    {
        NPCScript npc = GetComponent <NPCScript>();

        if (npc.dead == false)
        {
            if (curWaypoint < Waypoints.Length)
            {
                Target        = Waypoints [curWaypoint].position;
                MoveDirection = Target - transform.position;
                Velocity      = GetComponent <Rigidbody> ().velocity;

                if (MoveDirection.magnitude < 1)
                {
                    curWaypoint++;
                }
                else
                {
                    Velocity = MoveDirection.normalized * speed;
                }
            }
            else
            {
                if (doPatrol)
                {
                    curWaypoint = 0;
                }
                else
                {
                    Velocity = Vector3.zero;
                }
            }
            GetComponent <Rigidbody> ().velocity = Velocity;
            transform.LookAt(Target);
        }
        else
        {
            anim.SetBool("dead", true);
        }
    }
Пример #24
0
    void Update()
    {
        NPCScript npc = GetComponent <NPCScript>();

        if (npc.dead == false)
        {
            //Look at the player
            transform.LookAt(player);
            //Calculate distance between player
            float distance = Vector3.Distance(transform.position, player.position);
            //If the distance is smaller than the walkingDistance
            if (distance < walkingDistance)
            {
                //Move the enemy towards the player with smoothdamp
                transform.position = Vector3.SmoothDamp(transform.position, player.position, ref smoothVelocity, smoothTime);
            }
        }
        else
        {
            anim.SetBool("dead", true);
        }
    }
Пример #25
0
    // Update is called once per frame
    void Update()
    {
        if (!FightManager.InFight)
        {
            ParseMovement();
        }

        ParseInput();


        if (touching.Count > 0 && !FightManager.InFight)
        {
            foreach (GameObject other in touching)
            {
                if (other.tag == "CharNPC")
                {
                    NPCScript npc = other.gameObject.GetComponent <NPCScript>();
                    if (npc.HasDialog() && !DialogManager.Instance.IsOpen)
                    {
                        if (Input.GetButtonDown("Talk"))
                        {
                            DialogManager.Instance.StartDialog(npc);
                            ObjectText.RemoveTarget();
                        }
                        else
                        {
                            ObjectText.SetTarget(other.gameObject);
                        }
                    }
                }
            }
        }
        else
        {
            ObjectText.RemoveTarget();
        }
    }
Пример #26
0
 public void AddNPCScript(NPCScript n)
 {
     NPCList.Add(n);
 }
Пример #27
0
    // Update is called once per frame
    void Update()
    {
        //Toggle movement if Other events aren't happening. DialogSequence tells if there is dialog happening
        if(dialogSequence == false && StopKeyPressesonMainScreen == false)
        {
            //Turn on bool when key is down and off when up
            //Check which way the character is facing
            if(Input.GetKeyDown(KeyCode.W))
            {
                if( !down || !left || !right) forward = 1;
                up = true;
            }

            if(Input.GetKeyUp (KeyCode.W)) up = false;

            if(Input.GetKeyDown(KeyCode.A))
            {
                if( !down || !up || !right) forward = 2;
                left = true;
            }

            if(Input.GetKeyUp (KeyCode.A))	left = false;

            if(Input.GetKeyDown(KeyCode.S))
            {
                if( !left || !up || !right) forward = 4;
                down = true;
            }

            if(Input.GetKeyUp (KeyCode.S))	down = false;

            if(Input.GetKeyDown(KeyCode.D))
            {
                if( !left || !up || !down) forward = 3;
                right = true;
            }

            if(Input.GetKeyUp (KeyCode.D))	right = false;
        }

        //Check to move character
        //UP
        if(!Physics2D.Raycast(new Vector2(transform.position.x      ,transform.position.y   ),new Vector2(0,1),.55f) &&
           !Physics2D.Raycast(new Vector2(transform.position.x + .4f,transform.position.y   ),new Vector2(0,1),.55f) &&
           !Physics2D.Raycast(new Vector2(transform.position.x - .4f,transform.position.y   ),new Vector2(0,1),.55f) &&
            up)
        {
            transform.position += new Vector3(0, .1f ,0);
        }

        //LEFT
        if(!Physics2D.Raycast(new Vector2(transform.position.x      ,transform.position.y      ),new Vector2(-1,0),.55f) &&
           !Physics2D.Raycast(new Vector2(transform.position.x      ,transform.position.y + .4f),new Vector2(-1,0),.55f) &&
           !Physics2D.Raycast(new Vector2(transform.position.x      ,transform.position.y - .4f),new Vector2(-1,0),.55f) &&
           left)
        {
            transform.position += new Vector3(-.1f, 0 ,0);
        }

        //DOWN
        if(!Physics2D.Raycast(new Vector2(transform.position.x      ,transform.position.y     ),new Vector3(0,-1),.55f) &&
           !Physics2D.Raycast(new Vector2(transform.position.x + .4f,transform.position.y     ),new Vector3(0,-1),.55f) &&
           !Physics2D.Raycast(new Vector2(transform.position.x - .4f,transform.position.y     ),new Vector3(0,-1),.55f) &&
           down)
        {
            transform.position += new Vector3(0, -.1f ,0);
        }

        //RIGHT
        if(!Physics2D.Raycast(new Vector2(transform.position.x      ,transform.position.y      ),new Vector3(1,0),.55f) &&
           !Physics2D.Raycast(new Vector2(transform.position.x      ,transform.position.y + .4f),new Vector3(1,0),.55f) &&
           !Physics2D.Raycast(new Vector2(transform.position.x      ,transform.position.y - .4f),new Vector3(1,0),.55f) &&
           right)
        {
            transform.position += new Vector3(.1f, 0 ,0);
        }

        //Check for hit in front of where the player if facing
        if(forward == 1)	hit = Physics2D.Raycast(new Vector2(transform.position.x ,transform.position.y ),new Vector2(0,1) ,.55f); //up
        if(forward == 2)	hit = Physics2D.Raycast(new Vector2(transform.position.x ,transform.position.y ),new Vector2(-1,0),.55f); //left
        if(forward == 3)	hit	= Physics2D.Raycast(new Vector2(transform.position.x ,transform.position.y ),new Vector3(1,0) ,.55f); // right
        if(forward == 4)	hit = Physics2D.Raycast(new Vector2(transform.position.x ,transform.position.y ),new Vector3(0,-1),.55f); // down

        //if(hit != null) Debug.Log (hit.collider.name);
        if(hit.collider != null)
        {
            if(hit.collider.name == "NPC" && Input.GetKeyDown(KeyCode.Space))
            {
                dialogSequence = true;
                dialogMarker++;

                //Get script on NPC
                dialogscript = (NPCScript)hit.collider.GetComponent("NPCScript");
                //Add Talking Sequence

                if(dialogMarker < dialogscript.dialog.Length)
                {
                    Debug.Log(dialogscript.dialog[dialogMarker]);
                    dialogContent = new GUIContent(dialogscript.dialog[dialogMarker]);
                }
                else
                {
                    dialogSequence = false;
                    dialogMarker = -1;
                    up = false;
                    down = false;
                    left = false;
                    right = false;
                }
            }

            if(hit.collider.name == "Door" && Input.GetKeyDown(KeyCode.Space))
            {
                Debug.Log("DETECTED DOOR"); //Add Transfer to new scene
            }
        }
    }
Пример #28
0
    void setDistanceText(NPCScript entity)
    {
        int distance = (int)Mathf.Floor(Vector3.Distance(entity.transform.position, PlayerScript.mSingleton.transform.position));

        if (distance < 13)
        {
            entity.DistanceText.color = Color.red;
        }
        else if (distance >= 13 && distance < 22)
        {
            entity.DistanceText.color = Color.yellow;
        }

        else if (distance >= 22)
        {
            entity.DistanceText.color = Color.green;
        }
        entity.DistanceText.text = distance.ToString() + " m";
    }
Пример #29
0
 public void SetNPCParent(NPCScript npc)
 {
     NPCParent = npc;
 }
Пример #30
0
    // Update is called once per frame
    void Update()
    {
        player1Script = Player1.GetComponent <PlayerScript>();

        if (player1Script.shootTarget != null)
        {
            targetNPC = player1Script.shootTarget.gameObject.GetComponent <NPCScript>();
        }


        if (currentGameState == gameState.Gameplay && player1Script.walkInput == true)
        {
            playerNeverWalked = false;
        }
        // if (currentGameState == gameState.Intro)
        // {
        // Debug.Log("player should be moving");
        //  Player1.transform.position = this.transform.position;
        //}

        if (currentGameState == gameState.Intro)
        {
            player1Script.enabled = false;
            Debug.Log("player should be moving");
            Player1.transform.position = this.gameObject.transform.position;
            playerModel.SetActive(false);
        }

        if (anim.GetCurrentAnimatorStateInfo(0).IsName("SaucerStopped"))
        {
            player1Script.enabled = true;
            playerModel.SetActive(true);
            currentGameState = gameState.Gameplay;
        }

        timerText.text      = timer.ToString();
        careInShipText.text = careInShip + "/" + careCapacity;  //careInShip.ToString("/" + careCapacity);

        distanceToPlayer = Vector3.Distance(Player1.transform.position, this.transform.position);
        playerCare       = player1Script.CAREstolen;

        //temp TUTORIAL LOGIC
        //This is chris from the past. I know you're planning on disabling the timer during the tutorial... but this code relies on it... you're welcome

        if (timer >= (timerMax - 10f) && currentGameState == gameState.Gameplay)
        {
            Debug.Log("opening tut showing");
            //tutorial.gameObject.SetActive(true);
            showTutorial();
            tutorial.text = "Welcome to E-Arth. Your mission: Collect C.A.R.E from Humanoids. Dispense it into the ship.";
        }
        //790 788

        /*     if (timer <= (timerMax - 10f) && timer >= (timerMax - 12f) && currentGameState == gameState.Gameplay)
         *   {
         *       Debug.Log("set opening tut to inactive ");
         *       // tutorial.gameObject.SetActive(false);
         *       hideTutorial();
         *
         *   }*/

        //This is chris from the past. I know you're planning on disabling the timer during the tutorial... but this code relies on it... you're welcome
        if (timer <= (timerMax - 20f) && timer >= (timerMax - 23f) && currentGameState == gameState.Gameplay && playerNeverWalked)
        {
            Debug.Log("wasd tut showing");
            //tutorial.gameObject.SetActive(true);
            showTutorial();
            tutorial.text = "Use WASD to move";
        }

        /*else
         *  //if (timer <= (timerMax - 20f) && playerNeverWalked == false)
         * if (playerNeverWalked == false && tutorial.text == "Use WASD to move")
         * {
         *  Debug.Log("set WASD to inactive ");
         *  //tutorial.gameObject.SetActive(false);
         *  tutorial.text = "clear";
         *  hideTutorial();
         * }*/
        float distanceToTutWoman = Vector3.Distance(Player1.transform.position, tutorialFirstWoman.transform.position);

        //float fleeTutorialTimer = 5;


        if (distanceToTutWoman <= 300 && tutorialFirstWoman != null && tutorialFirstWoman.currentBehavior == NPCScript.behaviorState.Fleeing && fleeTutorialTimer >= 0) //&& tutorial.text != "Humans will flee if they see you.")
        {
            Debug.Log("SHOWING FLEEING TUTORIAL");
            showTutorial();
            tutorial.text      = "Humans will flee if they see you.";
            fleeTutorialTimer -= 1 * Time.deltaTime;
        }

        if (tutorialSecondMan != null)
        {
            distanceToSecond = Vector3.Distance(Player1.transform.position, tutorialSecondMan.gameObject.transform.position);
        }


        if (tutorialSecondMan != null && tutorialSecondMan.drained == false && distanceToSecond <= 25 && hasntSeenYou >= 0)
        {
            showTutorial();
            tutorial.text = "That one hasnt seen you. Walk behind it and harvest some C.A.R.E";
            hasntSeenYou -= 1 * Time.deltaTime;
        }


        if (tutorialSecondMan != null && tutorialSecondMan.drained == false && distanceToSecond <= 15 && lightTut >= 0)
        {
            showTutorial();
            tutorial.text = "The light on your gun will turn yellow when in range.";
            lightTut     -= 1 * Time.deltaTime;
        }

        if (tutorialSecondMan == null && tutorial.text == "The light on your gun will turn yellow when in range." && radiationTut >= 0)
        {
            showTutorial();
            tutorial.text = "The radiation from your gun will combust humans if you get too close to them...";
            radiationTut -= 1 * Time.deltaTime;
        }

        if (tutorialSecondMan != null && tutorialSecondMan.drained == true && collectedCARETut >= 0)
        {
            showTutorial();
            tutorial.text     = "You have collected a humans CARE! Take it back the ship! Dont worry, the human will awaken soon.";
            collectedCARETut -= 1 * Time.deltaTime;
        }

        if (tutorialSecondMan != null && tutorialSecondMan.drained == true && distanceToSecond >= 10)
        {
            //move agent to collapsed dude
            Debug.Log("AGENT STUCK");
            tutorialAgent.currentBehavior   = NPCScript.behaviorState.Walking;
            tutorialAgent.currentWalkTarget = tutorialSecondMan.gameObject;
        }

        if (tutorialAgent != null)
        {
            distanceToTutAgent = Vector3.Distance(Player1.transform.position, tutorialAgent.transform.position);
        }

        if (tutorialAgent != null && tutorialAgent.drained == false && distanceToTutAgent <= 20 && hostileTut >= 0)
        {
            tutorial.text = "A human hostile! Don't let it see you or you will be captured!";
        }

        if (tutorialAgent != null && tutorialAgent.drained == true && startTut >= 0)
        {
            tutorial.text = "Threat nuetralized. You now have 15 E-Arth minutes to complete your mission...";
            //wait 5 seconds
            //begin countdown
            //change to gameplaymode
        }

        //distance between agent and guy facing wrong way
        if (tutorialAgent != null && tutorialSecondMan != null)
        {
            float distanceFromAgentToTut = Vector3.Distance(tutorialAgent.transform.position, tutorialSecondMan.transform.position);

            if (tutorialAgent != null && tutorialSecondMan != null && tutorialSecondMan.drained == true && distanceFromAgentToTut <= 5)
            {
                //move agent to collapsed dude
                tutorialAgent.currentBehavior = NPCScript.behaviorState.Idle;
                //tutorialAgent.currentWalkTarget = tutorialSecondMan.gameObject;
            }
        }


        /*
         * if (tutorialAgent.currentBehavior == NPCScript.behaviorState.Walking)
         * {
         *  tutorialAgent.currentBehavior = NPCScript.behaviorState.Idle;
         * }*/

        if (distanceToPlayer < 5 && player1Script.CAREstolen > 0 && !dispensing)
        {
            Debug.Log("dispense tut showing");
            //tutorial.gameObject.SetActive(true);
            showTutorial();
            tutorial.text = "Stand under your ship and hold Right Mouse Button to dispense C.A.R.E";
        }
        else
        if (dispensing)
        {
            Debug.Log("dispense tut closed");
            //tutorial.gameObject.SetActive(false);
            hideTutorial();
        }

        if (player1Script.goldieLocks && player1Script.distanceToClosestNPC < 50 && targetNPC.drained == false)
        {
            Debug.Log("close to harvest tut showing");
            // tutorial.gameObject.SetActive(true);
            showTutorial();
            tutorial.text = "Use Left Mouse button to harvest C.A.R.E";
        }

        /* else
         * if(tutorial.text == "Use Left Mouse button to harvest C.A.R.E")
         * {
         *   Debug.Log("tut closed");
         *   hideTutorial();
         *   //tutorial.gameObject.SetActive(false);
         *
         * }
         * /*
         *   if (timer <= (timerMax - 5f) && currentGameState == gameState.Gameplay)
         * {
         *   tutorial.gameObject.SetActive(false);
         *
         * }*/


        if (timerActive && currentGameState == gameState.Gameplay)
        {
            timer -= 1 * Time.deltaTime;

            if (timer < 60)
            {
                timerText.color = Color.red;
            }

            if (timer <= 0)
            {
                Debug.Log("TIME UP");

                timer = 0;
                timeUp();
            }
        }


        // if ()

        if (Input.GetButton("Fire2"))
        {
            // if not too close and not too far and //not too far from cube
            if (distanceToPlayer < 5 && playerCare > 0f)
            {
                //assign that NPC to target
                //playerScript1.shootTarget = this.transform;
                Debug.Log("Dispencing CARE");
                //start draining
                dispensing = true;
                //playerScript1.distanceLight.color = Color.green;
            }


            /*
             * if (timer <= (timerMax - 5f) && currentGameState == gameState.Gameplay)
             * {
             *  Debug.Log("set inactive 4");
             *  //tutorial.gameObject.SetActive(false);
             *  hideTutorial();
             * }
             */
        }
        if (Input.GetButtonUp("Fire2") || playerCare <= 0 || distanceToPlayer >= 5f)
        {
            dispensing = false;
        }

        if (dispensing)
        {
            player1Script.CAREstolen -= 5 * Time.deltaTime;
            careInShip += 5 * Time.deltaTime;
        }

        //timeUp()
        // {

        // }
    }
Пример #31
0
 public void RemoveNPCScript(NPCScript n)
 {
     NPCList.Remove(n);
 }
Пример #32
0
    public IEnumerable TalkTrefor(WorldClient c, NPCScript n)
    {
        if (QuestActive(c, this.Id))
        {
            switch(QuestObjective(c, this.Id))
            {
                case "talk_trefor":
                {
                    FinishQuestObjective(c, this.Id, "talk_trefor");

                    n.Msg(c, "Welcome, I am Trefor, the guard.<br/>Someone from the town went into Alby Dungeon a while ago, but hasn't returned yet.<br/>I wish I could go there myself, but I can't leave my post. I'd really appreciate it if you can go and look for in Alby Dungeon.");
                    n.Msg(c, "Since the dungeon is a dangerous place to be in, I'll teach you a skill that will help you in an emergency situation.<br/>It's called the Smash skill. If you use it, you can knock down a monster with a single blow!<br/>It is also highly effective when you sneak up on a target and deliver the blow without warning.");
                    n.Msg(c, "Against monsters that are using the Defense skill,<br/>Smash will be the only way to penetrate that skill and deliver a killer blow.");
                    n.Msg(c, "However... looking at the way you're holding your sword, I'm not sure if you are up to the task.<br/>Let me test your skills first. Do you see those brown foxes wandering in front of me?<br/>They're quite a nuisance, praying on those roosters in town.<br/>I want you to go and hunt 5 Young Brown Foxes right now.");
                    n.Msg(c, "Foxes use the Defense Skill a lot, and as I told you before, regular attacks do not work against defending targets.<br/>That's then the Smash skill comes in handy.<br/><br/>Watch how I do it, and try picking up the important parts so you can use it too.<br/>You don't need to overstrain yourself by going for the Brown Foxes. Young Brown Foxes will do just fine.", n.Movie("skillbar_guide_us.wmv", 500, 300), n.Button("Continue"));
                    var r = n.Select(c);
                    n.Close(c);

                    var scene = new MabiCutscene(c.Character, "tuto_smash");
                    scene.AddActor("me", c.Character);
                    scene.AddActor("#trefor", n.NPC);
                    scene.AddActor("#brownfox", c.Character);
                    scene.Play(c);

                    Stop();
                }
                break;
                case "talk_trefor2":
                {
                    FinishQuestObjective(c, this.Id, "talk_trefor2");

                    n.Msg(c, "Good, I see that you're getting the hang of it.<br/>Well, I was able to do that when I was 8, but whatever...<br/>It is now time for you to go and search for the missing Villager.");
                    n.Msg(c, "Follow the road up and turn right and you'll find the Alby Dungeon.<br/>You can enter the dungeon by dropping this item on the altar.<br/>If you either lose it or fail to rescue her, come back to me so I can give you another one. Please be careful.", n.Image("dungeonpass", 128, 128));

                    n.GiveItem(c, 63140, 1);

                    Break();
                }
                break;
            }
        }

        End();
    }
Пример #33
0
 public bool RemoveSelection(NPCScript n)
 {
     NPCSelectList.Remove(n); return(true);
 }
Пример #34
0
    IEnumerator Interaction(NPCScript npc)
    {
        while (GameControl.gameState == (int)GameControl.GameState.HumanInteraction)
        {
            //disable mouselook
            GameControl.player.GetComponent <PlayerController>().disableMove = true;
            GameControl.player.GetComponent <PlayerController>().EnableMouseLook(false);
            if (dialogueState == (int)DialogueState.Greeting)
            {
                diaglogueTextComp.text = greetings[0];
                yield return(new WaitForSeconds(0.5f));

                //show main actions
                ShowMainActions();
                dialogueState = (int)DialogueState.MainActions;
                //dialogueState = (int)DialogueState.Test;
            }
            else if (dialogueState == (int)DialogueState.Test)
            {
                dialogueState = (int)DialogueState.EndDialogue;
            }
            //current dialogue panel shows main action options to player
            else if (dialogueState == (int)DialogueState.MainActions)
            {
                yield return(new WaitForSeconds(1f / 30f));
            }
            else if (dialogueState == (int)DialogueState.MainActionCancelDialogue)
            {
                yield return(new WaitForSeconds(1f / 30f));

                dialogueState = (int)DialogueState.EndDialogue;
            }
            else if (dialogueState == (int)DialogueState.MainActionBegMoney)
            {
                npc.beggedToday = true;
                yield return(new WaitForSeconds(0.5f));

                begItem = (int)BegItem.Money;
                if (npc.temper < 0.6)
                {
                    //bad temper
                    diaglogueTextComp.text = "urhhh...god...why?";
                }
                else
                {
                    //neutral
                    diaglogueTextComp.text = "I'm sorry, but may I ask why?";
                }
                dialogueState = (int)DialogueState.SubActionBeg;
            }
            else if (dialogueState == (int)DialogueState.SubActionBeg)
            {
                //if player chose badguy 0, 1, 2
                yield return(new WaitForSeconds(0.5f));

                ShowSubactions();
                //give money

                //dialogueState = (int)DialogueState.Decision;
            }
            else if (dialogueState == (int)DialogueState.Decision)
            {
                yield return(new WaitForSeconds(1f / 30f));

                //TODO: make decison

                int money = MakeDecision(npc.temper);
                //show text
                if (money > 0)
                {
                    diaglogueTextComp.text = "Alright, here you go man!";
                }
                else
                {
                    diaglogueTextComp.text = "Sorry I don't have change on me.";
                }
                yield return(new WaitForSeconds(1f / 3f));

                ShowDecision(money);
                yield return(new WaitForSeconds(2f));

                dialogueState = (int)DialogueState.EndDialogue;
            }
            else if (dialogueState == (int)DialogueState.EndDialogue)
            {
                Debug.Log("here");
                diaglogueCanvas.SetActive(false);
                PlayerController.self.EnableMouseLook(true);
                PlayerController.self.disableMove = false;
                GameControl.gameState             = (int)GameControl.GameState.PlayerNavigating;
                //Debug.Log("from dialogue: " + GameControl.gameState);
                ResetDialogueSys();
            }
        }        //end while
    }
Пример #35
0
    void playerMovementInput()
    {
        bool moved = false;
        Dir  dir   = null;

        if (Input.GetKeyDown(KeyCode.W))
        {
            dir = new Dir("up");
        }
        if (Input.GetKeyDown(KeyCode.A))
        {
            dir = new Dir("left");
        }
        if (Input.GetKeyDown(KeyCode.S))
        {
            dir = new Dir("down");
        }
        if (Input.GetKeyDown(KeyCode.D))
        {
            dir = new Dir("right");
        }
        if (dir != null)
        {
            int moveResult = checkMove(dir);
            Debug.Log("checkMove returned " + moveResult);
            //0 means we can move
            if (moveResult == 0)
            {
                move(dir);
                moved = true;
            }
            //1 means bad tile
            else if (moveResult == 1)
            {
                //do nothing now, might log later
            }
            //2 means furniture in way
            else if (moveResult == 2)
            {
                //should either log or maybe prompt for open
            }
            else if (moveResult == 3)
            {
                Vector2 loc = new Vector2(this.transform.position.x + dir.horz, this.transform.position.y + dir.vert);

                GameObject[] objs;
                objs = GameObject.FindGameObjectsWithTag("NPC");
                GameObject npc       = findInScene(objs, loc);
                NPCScript  npcScript = npc.GetComponent <NPCScript>();
                PlayerVars npcVars   = npc.GetComponent <PlayerVars>();

                if (npcScript.hostile)
                {
                    Debug.Log("REEEEEEEEEEE");
                    vars.attack(npcVars);
                }
            }
        }

        if (moved)
        {
            Vector2 loc = new Vector2(this.transform.position.x, this.transform.position.y);
            if (checkForItems(loc))
            {
                //log items
            }
        }
    }