Skip to content

Commit

Permalink
Refactor, typing commands to character, relax animation
Browse files Browse the repository at this point in the history
  • Loading branch information
xlar54 committed Aug 4, 2017
1 parent db70980 commit 13a7ac2
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 63 deletions.
Binary file modified Assets/Animations/lcp-man.controller
Binary file not shown.
Binary file added Assets/Animations/relaxing.anim
Binary file not shown.
9 changes: 9 additions & 0 deletions Assets/Animations/relaxing.anim.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Assets/Scenes/Main.unity
Binary file not shown.
90 changes: 28 additions & 62 deletions Assets/Scripts/LcpManController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public enum Activities
Phone,
Attic,
Closet,
Refrigerator
Refrigerator,
WashDishes
}
public enum CharacterStates
{
Expand Down Expand Up @@ -108,62 +109,7 @@ private void Update()

private void HandleInput()
{
if (Input.GetKeyDown("v"))
{
activityQueue.Push(Activities.TVChair);
}

if (Input.GetKeyDown("s"))
{
activityQueue.Push(Activities.Sleep);
}

if (Input.GetKeyDown("t"))
{
activityQueue.Push(Activities.Toilet);
}

if (Input.GetKeyDown("b"))
{
activityQueue.Push(Activities.ReadBook);
}
if (Input.GetKeyDown("w"))
{
activityQueue.Push(Activities.Typewriter);
}

if (Input.GetKeyDown("e"))
{
activityQueue.Push(Activities.Exercise);
}

if (Input.GetKeyDown("f"))
{
activityQueue.Push(Activities.Cupboard);
}

if (Input.GetKeyDown("l"))
{
activityQueue.Push(Activities.LeaveHouse);
}

if (Input.GetKeyDown("z"))
{
activityQueue.Push(Activities.Attic);
}
if (Input.GetKeyDown("x"))
{
activityQueue.Push(Activities.Closet);
}
if (Input.GetKeyDown("r"))
{
activityQueue.Push(Activities.Sofa);
}




if (Input.GetKeyDown("a"))
if (isControlKeyPressed() && Input.GetKeyDown(KeyCode.A))
{
GameObject.Find("Alarm_clock").GetComponent<AudioSource>().Play();
if (currentActivity == Activities.Sleep)
Expand All @@ -173,10 +119,11 @@ private void HandleInput()
}
}

if (Input.GetKeyDown("c"))
if (isControlKeyPressed() && Input.GetKeyDown(KeyCode.C))
{
GameObject.Find("Phone_Base").GetComponent<PhoneController>().state = PhoneController.States.ringing;
activityQueue.Push(Activities.Phone);
FinishedActivity(currentActivity);
}

if (Input.GetKeyDown(KeyCode.Escape))
Expand All @@ -185,6 +132,11 @@ private void HandleInput()
}
}

private bool isControlKeyPressed()
{
return Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
}

void GoToActivity(Activities activity)
{
if (activity == Activities.TV)
Expand Down Expand Up @@ -258,6 +210,9 @@ void GoToActivity(Activities activity)

if (activity == Activities.Refrigerator)
StartWalk(1, new Vector3(7.11f, 2.1f, 1.95f), Path.FacingDirection.backward, 3);

if (activity == Activities.WashDishes)
StartWalk(1, new Vector3(5.22f, 2.1f, 1.63f), Path.FacingDirection.backward, 5);
}

void StartActivity(Activities activity)
Expand All @@ -275,7 +230,7 @@ void StartActivity(Activities activity)
PlaySound("speak1", true);
}

if (currentActivity == Activities.BathroomSink)
if (currentActivity == Activities.BathroomSink || currentActivity == Activities.WashDishes)
{
PlaySound("sink", true);
}
Expand All @@ -301,7 +256,15 @@ void StartActivity(Activities activity)
if (GameObject.Find("Book").GetComponent<MeshRenderer>().enabled == true)
characterModel.GetComponent<Animator>().SetBool("isReading", true);
else
characterModel.GetComponent<Animator>().SetBool("isSitting", true);
{
int r = UnityEngine.Random.Range(1, 3);

if (r == 1)
characterModel.GetComponent<Animator>().SetBool("isSitting", true);
else
characterModel.GetComponent<Animator>().SetBool("isRelaxing", true);
}

}

if (currentActivity == Activities.Phone)
Expand All @@ -325,7 +288,8 @@ void StartActivity(Activities activity)
}

if (currentActivity == Activities.Cupboard || currentActivity == Activities.ComputerDesk
|| currentActivity == Activities.Typewriter || currentActivity == Activities.BathroomSink || currentActivity == Activities.Piano)
|| currentActivity == Activities.Typewriter || currentActivity == Activities.BathroomSink
|| currentActivity == Activities.Piano || currentActivity == Activities.WashDishes)
{
characterModel.GetComponent<Animator>().SetBool("isDoing", true);
}
Expand Down Expand Up @@ -574,6 +538,7 @@ private void StopAnimations()
characterModel.GetComponent<Animator>().SetBool("isEating", false);
characterModel.GetComponent<Animator>().SetBool("isExercising", false);
characterModel.GetComponent<Animator>().SetBool("isReading", false);
characterModel.GetComponent<Animator>().SetBool("isRelaxing", false);

GameObject.Find("Shower").GetComponent<ParticleSystem>().Stop();
GetComponent<AudioSource>().Stop();
Expand All @@ -593,7 +558,7 @@ Activities GetNextActivity()
return Activities.Sleep;
}

int nextActivity = UnityEngine.Random.Range(1, 24);
int nextActivity = UnityEngine.Random.Range(1, 25);

switch (nextActivity)
{
Expand All @@ -620,6 +585,7 @@ Activities GetNextActivity()
case 21: return Activities.Phone;
case 22: return Activities.Attic;
case 23: return Activities.Closet;
case 24: return Activities.WashDishes;
}

return Activities.FrontDoor;
Expand Down
94 changes: 93 additions & 1 deletion Assets/Scripts/TypewriterController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
Expand Down Expand Up @@ -141,6 +142,9 @@ private IEnumerator PlayerInput(string v)

TypewriterHead.transform.position = typewriterHeadDefaultPosition;
lastPlayerEntered = TextLines[TextLines.Count - 2].text;

PlayerInputHandler(lastPlayerEntered);

}
else if(s == "\b")
{
Expand Down Expand Up @@ -181,4 +185,92 @@ private IEnumerator PlayerInput(string v)

Hide();
}

private void PlayerInputHandler(string input)
{
GameObject go = GameObject.Find("character");

input = input.ToLower();

if (input.Contains("please"))
{
if(input.Contains("read"))
{
go.GetComponent<LcpManController>().activityQueue.Push(LcpManController.Activities.ReadBook);
}

if (input.Contains("type") || input.Contains("write") || input.Contains("letter"))
{
go.GetComponent<LcpManController>().activityQueue.Push(LcpManController.Activities.Typewriter);
}

if (input.Contains("tv") || input.Contains("television"))
{
go.GetComponent<LcpManController>().activityQueue.Push(LcpManController.Activities.TVChair);
}

if (input.Contains("sleep") || input.Contains("bed") || input.Contains("bedtime"))
{
go.GetComponent<LcpManController>().activityQueue.Push(LcpManController.Activities.Sleep);
}

if (input.Contains("sofa") || input.Contains("relax") || input.Contains("rest"))
{
go.GetComponent<LcpManController>().activityQueue.Push(LcpManController.Activities.Sofa);
}

if (input.Contains("play") || input.Contains("piano") || input.Contains("music"))
{
go.GetComponent<LcpManController>().activityQueue.Push(LcpManController.Activities.Piano);
}

if (input.Contains("call") || input.Contains("telephone") || input.Contains("phone"))
{
go.GetComponent<LcpManController>().activityQueue.Push(LcpManController.Activities.Phone);
}

if (input.Contains("eat") || input.Contains("food") || input.Contains("dinner") || input.Contains("lunch") || input.Contains("breakfast"))
{
go.GetComponent<LcpManController>().activityQueue.Push(LcpManController.Activities.Cupboard);
}

if (input.Contains("fire") || input.Contains("fireplace") || input.Contains("chimney"))
{
go.GetComponent<LcpManController>().activityQueue.Push(LcpManController.Activities.BuildFire);
}

if (input.Contains("dressed") || input.Contains("clothes") || input.Contains("shirt"))
{
go.GetComponent<LcpManController>().activityQueue.Push(LcpManController.Activities.Closet);
}

if (input.Contains("shower") || input.Contains("bath"))
{
go.GetComponent<LcpManController>().activityQueue.Push(LcpManController.Activities.Shower);
}

if (input.Contains("leave") || input.Contains("bye"))
{
go.GetComponent<LcpManController>().activityQueue.Push(LcpManController.Activities.LeaveHouse);
}

if (input.Contains("exercise"))
{
go.GetComponent<LcpManController>().activityQueue.Push(LcpManController.Activities.Exercise);
}

if (input.Contains("dishes"))
{
go.GetComponent<LcpManController>().activityQueue.Push(LcpManController.Activities.WashDishes);
}

}

if (input == "help")
{
TextLines[0].text = "Try saying 'please' before a command!";
TextLines[1].text = "CTRL-A = alarm clock, wake up";
TextLines[2].text = "CTRL-C = call";
}
}
}
Binary file modified ProjectSettings/GraphicsSettings.asset
Binary file not shown.

0 comments on commit 13a7ac2

Please sign in to comment.