示例#1
0
 // Use this for initialization
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
示例#2
0
    public void AddExp(float amount)
    {
        currentExp += amount;
        ShowStats.addMessage("You have gained " + amount + " exp");
        float expTop = 100.0f * Mathf.Pow(1.2f, level);

        while (currentExp >= expTop)
        {
            level++;
            currentExp -= expTop;
            ShowStats.addMessage("LEVEL UP: Lv " + level);
            LevelUp();
            //Debug.Log ("LEVELUP:" + level);
        }
    }
示例#3
0
 // Update is called once per frame
 void Update()
 {
     CheckConsume();
     if (Input.GetMouseButtonDown(0))
     {
         Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit hit;
         if (Physics.Raycast(ray, out hit, Mathf.Infinity, ~(1 << 10)))
         {
             if (hit.transform.gameObject.Equals(gameObject))
             {
                 ShowStats.StartConversation(this);
                 portraitCamera.enabled = true;
             }
         }
     }
 }
示例#4
0
    void CheckBroadcasts()
    {
        //Debug.Log (ConversationScript.broadcasts);

        if (ConversationScript.FindAndRemoveBroadcast("GoToBox1"))
        {
            CreateBoxLights(platforms[0]);
            ShowStats.addMessage("-----------------------");
            ShowStats.addMessage("Use A and D keys to move left and right.");
            ShowStats.addMessage("Press space key to jump.");
        }
        if (ConversationScript.FindAndRemoveBroadcast("Run1"))
        {
            ConversationScript con = GameObject.Find("TutorialGuide").GetComponent <ConversationScript>();
            //con.CameraOn();
            ShowStats.StartConversation(con, 4);
            CreateBoxLights(platforms[1]);

            HorizontalFlashingRedArrow.start = true;
            ShowStats.addMessage("-----------------------");
            ShowStats.addMessage("Hold shift key to sprint.");
        }
        if (ConversationScript.FindAndRemoveBroadcast("ShiftJump"))
        {
            ShowStats.StartConversation(GameObject.Find("TutorialGuide").GetComponent <ConversationScript>(), 5);
            CreateBoxLights(platforms[2]);
            ShowStats.addMessage("-----------------------");
            ShowStats.addMessage("Hold shift and space to long jump.");
            HorizontalFlashingRedArrow.start = false;
        }
        if (ConversationScript.FindAndRemoveBroadcast("Fight"))
        {
            ShowStats.StartConversation(GameObject.Find("TutorialGuide").GetComponent <ConversationScript>(), 6);
            ShowStats.addMessage("-----------------------");
            ShowStats.addMessage("Press I to open inventory.");
        }
        if (ConversationScript.FindAndRemoveBroadcast("ReadyToFight"))
        {
            ShowStats.addMessage("-----------------------");
            ShowStats.addMessage("Left click to attack.");
        }
    }
示例#5
0
    void Start()
    {
        PlayerAnimator = GetComponent<Animator> ();
        this.keyStates = new Dictionary<string, bool>() { {"UP", false}, {"RIGHT", false}, {"DOWN", false}, {"LEFT", false}, {"ACTION", false} };
        lr = transform.GetComponent<LineRenderer>();

        hero = new PlayerStats(100, new Weapon(3, 2, 1), 20, 20, 20, 20);
        statsDisplay = GameObject.Find("Health").GetComponent<ShowStats>();
        statsDisplay.SetPlayerStats(hero);
        attacking = false;
    }
示例#6
0
 public ShowStatsTest()
 {
     action         = new ShowStats();
     controllerMock = new Mock <IGameController>();
 }
示例#7
0
 public void GainMoney(float amount)
 {
     money += amount;
     ShowStats.addMessage("Picked up " + amount + " coins.");
 }
示例#8
0
    // Update is called once per frame
    void Update()
    {
        //Debug.Log ("damage"+damageDealt);

        if (Input.GetKeyDown(KeyCode.F5))
        {
            Application.LoadLevel("platformer");
        }
        if (Input.GetKeyDown(KeyCode.F6))
        {
            Hit(100.0f);
            CheckDeath();
        }
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            Fireball();
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            LightningStrike();
        }
        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            FireBlast();
        }
        if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            IceBlast();
        }
        if (Input.GetKeyDown(KeyCode.Alpha5))
        {
            Heal();
        }
        if (Input.GetKeyDown(KeyCode.Alpha6))
        {
            Shield();
        }
        if (Input.GetKeyDown(KeyCode.Q))
        {
            Teleport();
        }
        if (Input.GetKeyDown(KeyCode.F1))
        {
            mute = !mute;
        }
        if (Input.GetKeyDown(KeyCode.I))
        {
            ShowStats.addMessage("Inventory is not yet finished.");
        }

        UpdateHealth();
        CheckIfDrowned();
        CheckDeath();
        CheckCombo();
        CheckMute();
        LowHealthEffect();
        CheckKillEverything();
        if (onfire && !godmode)
        {
            currentHealth -= fireDamage * Time.deltaTime;
        }
        //Debug.Log ("Health: " + currentHealth);

        GameObject tempClosest = FindClosestEnemy();

        if ((tempClosest == null && closestEnemy != null))
        {
            closestEnemy.GetComponent <HealthBar>().show = false;
        }
        if (tempClosest != null && !tempClosest.Equals(closestEnemy))
        {
            if (closestEnemy != null)
            {
                closestEnemy.GetComponent <HealthBar>().show = false;
                Debug.Log(closestEnemy.name);
            }
        }
        closestEnemy = tempClosest;


        InteractClosest();

        SetAnimationLayers();
        float forwardSpeed = Input.GetAxis("Horizontal") * ms * sprintSpeedVar * attackingMovementSlowVar;
        float sidewaySpeed = Input.GetAxis("Vertical") * sidems * sprintSpeedVar * attackingMovementSlowVar;

        if (!mode_3d)
        {
            sidewaySpeed = 0;
        }

        if (IsDead())
        {
            forwardSpeed = 0;
        }
        AddMana(Mathf.Abs(forwardSpeed) / 50.0f);
        if (forwardSpeed != 0)
        {
            justSpawned = false;
        }
        if (!justSpawned)
        {
            StopSpawnParticles();
        }

        if (forwardSpeed == 0 && sidewaySpeed != 0)
        {
            if (!walking)
            {
                //Debug.Log ("sideway");
                animation.CrossFade("Walk");
                audio.Play();
            }
            walking = true;
        }
        else if (forwardSpeed > 0 || sidewaySpeed != 0)
        {
            if (!walking)
            {
                animation.CrossFade("Walk");
                audio.Play();
            }
            walking = true;
            if (!forward)
            {
                Reverse();
                forward = true;
            }
        }
        else if (forwardSpeed < 0)
        {
            if (!walking)
            {
                animation.CrossFade("Walk");
                audio.Play();
            }
            walking = true;
            if (forward)
            {
                Reverse();
                forward = false;
            }
        }
        else
        {
            walking = false;
            idle    = true;
            audio.Stop();
        }

        if (Input.GetKey(KeyCode.LeftShift) && !idle)
        {
            sprintSpeedVar = sprintSpeed;

            animation.CrossFade("Run");
            running = true;
        }
        else
        {
            sprintSpeedVar = 1;
            running        = false;
            if (walking)
            {
                animation.CrossFade("Walk");
            }
            else if (idle)
            {
                animation.CrossFade("idle");
            }
            if (attacking)
            {
                animation.CrossFade("Attack");
            }
        }



        if (Input.GetButtonUp("Fire1") && !ShowStats.mouseConsumed)
        {
            Attack();
        }

        if (!walking && !running && !jumping && !attacking)
        {
            if (!idle)
            {
                animation.CrossFade("idle");
            }
            idle = true;
        }
        else
        {
            idle = false;
        }

        speed.z = forwardSpeed;
        speed.x = -sidewaySpeed;
        //speed = transform.rotation * speed;

        if (Input.GetButton("Jump") && !isFalling && !IsDead())
        {
            //animation.Stop ("Run");
            //animation.Stop ("idle");
            //animation.Stop ("Walk");
            Invoke("Jump", jumpDelay);
            isFalling = true;
            jumping   = true;
            animation.CrossFade("Jump");
            //Invoke ("ResumeAnimations", 1.0f);
            //Debug/.Log ("jumpcalled");
            //QAnimation ();
        }
        speed.y = speed.y - (gravity * Time.deltaTime);
        //execution
        cc.Move(speed * Time.deltaTime);

        if (forwardSpeed > 0 && sidewaySpeed > 0)
        {
            transform.localEulerAngles = new Vector3(0, -45, 0);
        }
        else if (forwardSpeed > 0 && sidewaySpeed < 0)
        {
            transform.localEulerAngles = new Vector3(0, 45, 0);
        }
        else if (forwardSpeed < 0 && sidewaySpeed > 0)
        {
            transform.localEulerAngles = new Vector3(0, 225, 0);            //180 and -90=270 = 225
        }
        else if (forwardSpeed < 0 && sidewaySpeed < 0)
        {
            transform.localEulerAngles = new Vector3(0, 135, 0);
        }
        else if (forwardSpeed > 0)
        {
            transform.localEulerAngles = new Vector3(0, 0, 0);
        }
        else if (forwardSpeed < 0)
        {
            transform.localEulerAngles = new Vector3(0, 180, 0);
        }
        else if (sidewaySpeed > 0)
        {
            transform.localEulerAngles = new Vector3(0, -90, 0);
        }
        else if (sidewaySpeed < 0)
        {
            transform.localEulerAngles = new Vector3(0, 90, 0);
        }

        //Debug.Log (speed);
        if (!mode_3d)
        {
            transform.position = new Vector3(1052.083f, transform.position.y, transform.position.z);
        }
        CheckIfGrounded();
    }
示例#9
0
 public void ReportKill(GameObject other)
 {
     ShowStats.addMessage("You have killed a " + other.name + ".");
     AddExp(other.GetComponent <TrollController>().expToGive);
 }
示例#10
0
 void LateIntro()
 {
     ShowStats.addMessage("-----------------------");
     ShowStats.addMessage("Talk to the NPC by clicking on him.");
 }