Inheritance: MonoBehaviour
Esempio n. 1
0
 PlayerBehaviour()
 {
     if(mInstance!=null) {
         Destroy(this);
     }
     mInstance=this;
 }
    //State methods
    private void WhileSearching()
    {
        //Stop firing
        machineGun.triggerPulled = false;

        //Rotate in a circle
        Vector3 euler = targetRot.eulerAngles;
        euler.x = 0;
        euler.y += searchRotSpeed * Time.deltaTime;
        targetRot.eulerAngles = euler;

        //Rotate towards the target rot
        transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRot, rotSpeed * Time.deltaTime);

        //Scan for a target
        List<PlayerBehaviour> hits = visionCone.Scan<PlayerBehaviour>();

        //Start attacking the first hit in the list
        if (hits.Count > 0)
        {
            target = hits[0].GetComponent<PlayerBehaviour>();
            currentState = State.attacking;

            //TODO: Play some kind of sound effect
        }
    }
Esempio n. 3
0
 public override void EndEvent(PlayerBehaviour _currentPlayer)
 {
     if (hatAnim != null)
     {
         GameObject.Destroy(hatAnim);
         hatAnim = null;
     }
 }
    void Start()
    {
        PlayerBehaviour = GameObject.FindWithTag ("Player").GetComponent<PlayerBehaviour>();

        scaleUSize = PlayerBehaviour.scaleUpSize;

        scaleSSize = PlayerBehaviour.scaleDownSize;
    }
Esempio n. 5
0
 public override void StartEvent(PlayerBehaviour _currentPlayer)
 {
     //Do a footstep thing? Like, play a sound? Why isn't this using Unity's drag and drop?
     if (DuelManagerBehaviour.Instance.footstepAnim != null)
     {
         GameObject step = (GameObject)GameObject.Instantiate(DuelManagerBehaviour.Instance.footstepAnim, _currentPlayer.transform.position + new Vector3(0f, -1.3f, 2f), Quaternion.identity);
     }
 }
Esempio n. 6
0
 public override void StartEvent(PlayerBehaviour _currentPlayer)
 {
     //Do an animation, but only if this is the first one to set one up...
     if (rabbitAnim == null)
     {
         rabbitAnim = GameObject.Instantiate<GameObject>(DuelManagerBehaviour.Instance.rabbitAnim);
     }
 }
Esempio n. 7
0
 public override void StartEvent(PlayerBehaviour _currentPlayer)
 {
     //Do an animation, but only if this is the first one to set one up...
     if (windAnim == null)
     {
         windAnim = GameObject.Instantiate<GameObject>(DuelManagerBehaviour.Instance.windAnim);
         windAnim.transform.position = new Vector3(Random.Range(-6f, 6f), Random.Range(0f, 2f), 0f);
     }
 }
    public bool MakeGuess(char guess, ref PlayerBehaviour player, int scoreVal)
    {
        Debug.Log(player.id + " IS MAKING GUESS WITH: " + guess.ToString());

        // Remove letter from remaining list when guessing correctly
        if (allLetters.Contains(char.ToUpper(guess)))
        {
            if (remainingCorrectLetters.Contains(char.ToUpper(guess)))
            {
                remainingCorrectLetters.Remove(char.ToUpper(guess));

                if (GameManager.Instance.clientPlayer.id == player.id)
                {
                    // Add score when player guesses correctly, add bonus score when player opens whole word
                    player.roundScore += scoreVal * charToIndexDict[char.ToUpper(guess)].Count; // Multiplier bonus
                }

                if (remainingCorrectLetters.Count <= 0 && GameManager.Instance.clientPlayer.id == player.id) // All letters have been correctly guessed
                {
                    player.roundScore += (int)Score.WHOLEWORDPOINT;
                    PlayerInfo.numWins++;
                }
            }
        }
        // Add letter to wrong list when guessing wrong
        else
        {
            if (!wrongLetters.Contains(char.ToUpper(guess)) && (guess != ' ' || guess != '\0'))
            {
                wrongLetters.Add(char.ToUpper(guess));
            }

            // Show list of missed letters on screen
            string wrongString = "";
            for (int i = 0; i < wrongLetters.Count; i++)
            {
                wrongString += wrongLetters[i].ToString();
                wrongString += (i == wrongLetters.Count - 1) ? "" : " , ";
            }
            missedLetters.faceColor = new Color32(251, 241, 24, 255);
            missedLetters.text      = wrongString;

            return(false);
        }

        // Test code - need better implementation
        if (charToIndexDict.ContainsKey(char.ToUpper(guess)))
        {
            foreach (int index in charToIndexDict[char.ToUpper(guess)])
            {
                solutionPanels[index].GetComponentInChildren <TextMeshProUGUI>().enabled = true;
            }
        }

        return(true); // Guessed correctly
    }
Esempio n. 9
0
    /**************************************************
    *   User Defined Functions
    **************************************************/

    /// <summary>
    /// 効果の付与
    /// </summary>
    /// <param name="target">付与対象</param>
    protected override void GiveEffect(PlayerBehaviour target)
    {
        target.GetHealed(1);

        GameObject healthPopup = Instantiate(healthPopupPrefab, target.gameObject.transform.position, Quaternion.identity, target.gameObject.transform.parent);

        healthPopup.GetComponent <ImagePopupBehaviour>().Initialize();

        base.GiveEffect(target);
    }
Esempio n. 10
0
 public override void StartEvent(PlayerBehaviour _currentPlayer)
 {
     //Do an animation, but only if this is the first one to set one up...
     if (hatAnim == null)
     {
         hatAnim = GameObject.Instantiate<GameObject>(DuelManagerBehaviour.Instance.hatAnim);
         hatAnim.transform.SetParent(_currentPlayer.transform);
         hatAnim.transform.localPosition = new Vector3(0f, 1f, 0.5f);
     }
 }
Esempio n. 11
0
    private void Init()
    {
        playerBehaviour = this;
        rigidbody2      = gameObject.GetComponent <Rigidbody2D>();
        gameManager     = GameFacade.GetInstance().gameManager;
        StartCoroutine(LoadData());


        //   gameObject.transform.parent.gameObject.transform.position = StartPosition.position;
    }
Esempio n. 12
0
 // Start is called before the first frame update
 void Start()
 {
     health         = 100;
     rigidbody2D    = GetComponent <Rigidbody2D>();
     rampDirection  = RampDirection.NONE;
     player         = GameObject.FindObjectOfType <PlayerBehaviour>();
     hitSound       = GetComponent <AudioSource>();
     animator       = GetComponent <Animator>();
     spriteRenderer = GetComponent <SpriteRenderer>();
 }
Esempio n. 13
0
    // Use this for initialization
    void Start()
    {
        player = FindObjectOfType <PlayerBehaviour>();

        if (player.transform.localScale.x < 0)
        {
            speed         = -speed;
            rotationSpeed = -rotationSpeed;
        }
    }
Esempio n. 14
0
 public PlayerCellphoneState(PlayerBehaviour player, Person target)
 {
     player.CellScreen.SetActive(true);
     GameObject.FindGameObjectsWithTag("Thinkbox").ToList().ForEach(tb => tb.SetActive(false));
     Debug.Log("Celphone");
     _player = player;
     _target = target;
     SetIcons(_target);
     currentApp = 0;
 }
Esempio n. 15
0
    private void OnCollisionEnter(Collision c)
    {
        PlayerBehaviour pb = c.gameObject.GetComponent <PlayerBehaviour>();

        if (pb != null)
        {
            pb.Manager.TakeDamage(Mathf.FloorToInt(rigidbody.velocity.sqrMagnitude / 8), manager.ShooterId);
            gameObject.SetActive(false);
        }
    }
Esempio n. 16
0
 // Start is called before the first frame update
 void Start()
 {
     shieldButton = GetComponent <Button>();
     shieldButton.onClick.AddListener(OnClick);
     player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerBehaviour>();
     if (player.ShieldBehaviour == null)
     {
         gameObject.SetActive(false);
     }
 }
 //玩家使用技能完毕
 public void OnSkillOver(PlayerBehaviour sender)
 {
     if (sender != currentPlayer)
     {
         Debug.Log("!="); return;
     }
     //更新显示玩家金钱等讯息
     SendPlayerMessageToUI();
     isSkillEnd = true;
 }
Esempio n. 18
0
    private void CmdAskReport(PlayerBehaviour reportPlayer)
    {
        float distance = Vector2.Distance(reportPlayer.transform.position, transform.position);

        if (reportPlayer.State == PlayerState.Dead && distance <= ReportDistance)
        {
            GameManager.Instance.ReportPlayerServer(reportPlayer, this);
            reportPlayer.RpcReport(this);
        }
    }
        public override bool OnInteract(PlayerBehaviour player)
        {
            if (isEnabled && itemStack.Count > 0 && player.HasStackSpace())
            {
                player.PushItemStack(popItemFromStack());
                return(true);
            }

            return(false);
        }
Esempio n. 20
0
    // Use this for initialization
    void Start()
    {
        text = gameObject.GetComponent<Text>();

        GameObject o = GameObject.Find("Player");
        if (o != null)
        {
            player = o.GetComponent<PlayerBehaviour>();
        }
    }
Esempio n. 21
0
    private void Start()
    {
        player = GetComponent <PlayerBehaviour>();

        if (!IsDebug)
        {
            InitializePlayerCards();
            SetCamera();
        }
    }
Esempio n. 22
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        PlayerBehaviour pB = collision.GetComponent <PlayerBehaviour>();

        if (pB != null)
        {
            pB.hitPoints += hitPointsAmount;
            Destroy(gameObject);
        }
    }
Esempio n. 23
0
    public int GetReserveAmmunition(int unitId, Weapon weapon)
    {
        if (CheckIfCorrectTeam(unitId))
        {
            PlayerBehaviour player = gc.GetPlayerBehaviours()[unitId];
            return(player.GetReserveAmmunition(weapon));
        }

        throw new System.UnauthorizedAccessException("Error: Can not access enemy reserve ammunition");
    }
Esempio n. 24
0
    public void Atacar(PlayerBehaviour alvo)
    {
        float distancia = Vector3.Distance(this.transform.position, alvo.transform.position);

        if (distancia < 2)
        {
            // TODO Animação de atacar com a baioneta(Coronhada).
            alvo.LevaDano(this.dano);
        }
    }
Esempio n. 25
0
 // Use this for initialization
 void Start()
 {
     player          = GameObject.FindWithTag("Player");
     playerTransform = player.transform;
     playerBehaviour = player.GetComponent <PlayerBehaviour>();
     anim            = GetComponent <Animator>();
     updateHealthBar();
     spawnScript = GameObject.FindGameObjectWithTag("Spawn").GetComponent <SpawnScript>();
     enemy       = GameObject.FindGameObjectWithTag("Enemy");
 }
Esempio n. 26
0
 /*
  *  Destroy the powerup and reset animation
  */
 protected virtual void removePowerUpEffect(PlayerBehaviour player)
 {
     // Then we destroy the powerup
     if (destoryable && !expiresOnTime)
     {
         Destroy(gameObject.transform.root.gameObject);
     }
     // and in all cases, reset the animation back
     player.setAnimation("Normal");
 }
Esempio n. 27
0
    private void OnCollisionEnter2D(Collision2D target)
    {
        if (target.gameObject.tag == "Player")
        {
            PlayerBehaviour player = target.gameObject.GetComponent <PlayerBehaviour>();
            player.TakeDamage(damage);
        }

        DecreaseEnergy();
    }
Esempio n. 28
0
 // Use this for initialization
 void Start()
 {
     GM = GameObject.Find("GameManager").GetComponent <GameManager>();
     playerBehaviour     = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerBehaviour>();
     PrS                 = GameObject.Find("InkSpray").GetComponent <ParticleSystem>();
     collisionEvents     = new List <ParticleCollisionEvent>();
     settings            = PrS.main;
     settings.startColor = new ParticleSystem.MinMaxGradient(ClearColour);
     ammoBehaviour       = FindObjectOfType <AmmoBehaviour>();
 }
Esempio n. 29
0
 public PlayerData(PlayerBehaviour player)
 {
     health      = player.currentHealth;
     position    = new float[3];
     position[0] = player.controller.transform.position.x;
     position[1] = player.controller.transform.position.y;
     position[2] = player.controller.transform.position.z;
     sword       = player.gotSword;
     shield      = player.gotShield;
 }
Esempio n. 30
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        PlayerBehaviour pB = collision.GetComponent <PlayerBehaviour>();

        if (pB != null)
        {
            pB.teleportCells += teleportCellAmount;
            Destroy(gameObject);
        }
    }
Esempio n. 31
0
    public void teleporte()
    {
        player = FindObjectOfType(typeof(PlayerBehaviour)) as PlayerBehaviour;

        player.gameObject.transform.position = new Vector3(-0.78f, -30f, -0.28f);

        player.addLife(30);

        //popUpDie.gameObject.SetActive(false);
    }
Esempio n. 32
0
 public void SetManager(Transform init)
 {
     _manager = init.root.GetComponentInChildren <FW02FSMManager>();
     attack   = _manager.GetComponentInChildren <FW02ATTACK>();
     player   = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerBehaviour>();
     pos      = attack.playerTrans;
     startPos = attack.FirePos;
     //Vector3.MoveTowards(pos, 5f * Time.deltaTime);
     //GetComponent<Rigidbody>().AddForce(transform.forward * speed);
 }
    /// <summary>
    /// Wenn der Spieler getroffen wird, ziehe ihm
    /// den Schaden ab, welcher im Inspector eingestellt ist.
    /// Der Schaden richtet sich nach der Geschwindigkeit, kann aber niemals
    /// den Schaden aus dem Inspector überschreiten.
    /// </summary>
    /// <param name="collision">Collision-Objekt</param>
    private void HandlePlayerCollision(Collision collision)
    {
        PlayerBehaviour player = collision.gameObject.GetComponent <PlayerBehaviour>();

        if (player != null)
        {
            float damage = Mathf.Clamp(damageFactor * rig.velocity.magnitude, 0.0f, damageFactor);
            player.LooseHealth(damage);
        }
    }
Esempio n. 34
0
 public void UseChangeBlockSkill(PlayerBehaviour player)
 {
     if (player == gameCharacter.controllingPlayer)
     {
         AudioSource.PlayClipAtPoint(gameCharacter.witchesLaughter[player.GameUiPosition], gameCharacter.gameObject.transform.position);
         parryActive = true;
         Debug.Log("BlockSkill");
         StartCoroutine(BlockDuration());
     }
 }
Esempio n. 35
0
    // Use this for initialization
    void Start()
    {
        player = FindObjectOfType <PlayerBehaviour>();

        if (player.transform.position.x < transform.position.x)
        {
            speed         = -speed;
            rotationSpeed = -rotationSpeed;
        }
    }
Esempio n. 36
0
    private void Start()
    {
        player    = GetComponent <PlayerBehaviour>();
        waterLine = GameController.instance.waterline;
        animLine  = GameController.instance.animline;

        //	Debug.Log("WE : " + waterLine);

        underwater = lastUnderwater = transform.position.y <= waterLine;
    }
Esempio n. 37
0
 // Start is called before the first frame update
 void Start()
 {
     navMeshAgent = GetComponent <NavMeshAgent>();
     animator     = GetComponent <Animator>();
     healthBar.SetMaxHealth(maxHealth);
     //currentHealth = maxHealth;
     originalPosition = transform.position;
     playerBehaviour  = player.GetComponent <PlayerBehaviour>();
     healthBar.SetHealth(currentHealth);
 }
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     pointsSystem   = new PointsSystem();
     spriteRenderer = GetComponent <SpriteRenderer>();
     animator       = GetComponent <SpriteRendererAnimator>();
 }
Esempio n. 39
0
    private void OnCollisionEnter(Collision collision)
    {
        PlayerBehaviour playerHit = collision.gameObject.GetComponent <PlayerBehaviour>();

        if (playerHit)
        {
            playerHit.SetPlayerState(PlayerState.Dead);
            //playerHit.transform.SetParent(transform);
        }
    }
Esempio n. 40
0
    // Use this for initialization
    void Start()
    {
        ScriptPlayer = Player.GetComponent<PlayerBehaviour>();

        var menu = GameObject.Find("Menu");
        MenuScript = menu.GetComponent<MenuBehaviour>();

        StartStage1();

        Instance = this;

    }
Esempio n. 41
0
	// Use this for initialization
	void Start () 
	{
		m_animator = GetComponent<Animator> ();
		m_playerBehaviour = new PlayerBehaviour (m_animator,transform,m_cam, m_aura,m_miniMonster,m_boss);

		m_inventoryNotOpen = false;
		m_visible = m_inventoryCanvas.GetComponent<CanvasGroup> ().alpha;
		m_healthSlider = GameObject.FindObjectOfType<Slider> ();
		m_health = 100;
		m_attack = 10;
		m_defence = 5;
	}
Esempio n. 42
0
	// Use this for initialization
	void Start () {
        hookStart = GameObject.Find("chainStart");
        player = GameObject.Find("Player");
        playerBehaviour = GameObject.Find("Player").GetComponent<PlayerBehaviour>();
        joint = GameObject.Find("Player").GetComponent<DistanceJoint2D>();
        joint.enabled = false;
        line = GameObject.Find("grapplinghook").GetComponent<LineRenderer>();
        line.enabled = false;        
        maxDistance = 20f;
        
        
	}
    //Events
	void Awake()
    {
		//Set the instance
		instance = this;
		
        //Swap to the first weapon.
        RightHandWeapon.OnSwapIn();

		//Lock the cursor
		Cursor.lockState = CursorLockMode.Locked;
		Cursor.visible = false;
        cursorCaptured = true;
	}
Esempio n. 44
0
    public void SwitchActivePlayer()
    {
        this.ActivePlayer.MyScore.text = this.ActivePlayer.power.ToString();

        if (this.ActivePlayer == Player1) {
            this.ActivePlayer = Player2;
        }
        else {
            this.ActivePlayer = Player1;
        }

        this.ActivePlayer.MyScore.text = this.ActivePlayer.power.ToString() + " <";
    }
    // Use this for initialization
    void Start()
    {
        player=FindObjectOfType(typeof(PlayerBehaviour)) as PlayerBehaviour;
        //meshSlender.enabled=false;

        //player.SetFeedBackAlpha(0.1f);

        gameController=FindObjectOfType(typeof(GameController)) as GameController;

        currentScareFactory=scareFactory;
        currentRadieusToSpawn=radiusToSpawn;

        arduino=FindObjectOfType(typeof(ArduinoConnection)) as ArduinoConnection;
    }
Esempio n. 46
0
    // Use this for initialization
    void Start()
    {
        gm = GameObject.FindObjectOfType<GameManager> ();
        if (gm != null) {
            lives = gm.numberOfLifes;
        } else {
            lives = 1;
        }
        freezIcon = GameObject.Find ("FreezeIcon");
        disappearIcon = GameObject.Find ("DisappearIcon");
        plScript = player.GetComponent<PlayerBehaviour> ();
        livesText = GameObject.Find ("LivesAmount");

        cfre = player.GetComponent<CubeFreezer> ();
        cdis = player.GetComponent<CubeDisappearer> ();
    }
Esempio n. 47
0
    void Start()
    {
        this.player = GameObject.FindGameObjectWithTag("Player");

        this.treadmillBehaviour = (TreadmillBehaviour)GameObject.Find ("Treadmill").GetComponent("TreadmillBehaviour");

        this.levelGenerator = new LevelGenerator( this.treadmillBehaviour );
        this.gameRunning = true;

        // Score TextMesh
        GameObject scoreText = GameObject.Find("ScoreText");
        this.scoreText = scoreText.GetComponent(typeof(TextMesh)) as TextMesh;

        // Listen for coin collection event
        this.playerBehaviour = this.player.GetComponent("PlayerBehaviour") as PlayerBehaviour;
        this.playerBehaviour.coinCollected += new PlayerBehaviour.CoinCollectedHandler( HandleCoinsCollected );
        this.playerBehaviour.SetTreadmill(this.treadmillBehaviour);
    }
Esempio n. 48
0
    public void AddPlayer(PlayerBehaviour player, bool keyboardControl)
    {
        players.Add(player, keyboardControl);
        player.SetModel((GameObject)Instantiate(player.GetModel(), playerSpawn, player.GetModel().transform.rotation));
        //player.SetShipModel();

        float distance = transform.position.z - UnityEngine.Camera.main.transform.position.z;
        Vector3 leftMost = UnityEngine.Camera.main.ViewportToWorldPoint(new Vector3(0, 0, distance));
        Vector3 rightMost = UnityEngine.Camera.main.ViewportToWorldPoint(new Vector3(1, 0, distance));
        xMin = leftMost.x + hPadding;
        xMax = rightMost.x - hPadding;

        Vector3 bottomMost = UnityEngine.Camera.main.ViewportToWorldPoint(new Vector3(0, 0, distance));
        Vector3 topMost = UnityEngine.Camera.main.ViewportToWorldPoint(new Vector3(0, 1, distance));
        yMin = bottomMost.y + vPadding + thrusterVSize;
        yMax = topMost.y - vPadding;

        minRotation = 90 - tiltAngle;
        maxRotation = 90 + tiltAngle;
    }
Esempio n. 49
0
 private void Start()
 {
     mBack= transform.GetChild(0).gameObject.GetComponent<Image>();
     mStartAlpha=mBack.color.a;
     mParentUI=transform.GetChild (1).gameObject;
     mPlayer=PlayerBehaviour.Singleton();
     imageToSet.material.EnableKeyword("_EMISSION");
 }
Esempio n. 50
0
    void OnTriggerEnter2D(Collider2D other)
    {
        //Debug.Log("OnTriggerEnter2D");
        layerName = LayerMask.LayerToName(other.gameObject.layer);

        switch (layerName)
        {
            case "Player":

                break;

            case "AI":
                if (canSpin)
                {
                    //other.gameObject.GetComponent<AIComponent> ().healthBar.SetActive (false);
                    //other.gameObject.GetComponent<AIComponent> ().Death ();
                }
                break;
            case "EnemyTrigger0":
                Debug.Log("touched trigger " + other.gameObject.name);
                LevelManager.instance.activateAISpawn[0] = true;
                other.gameObject.SetActive(false);
                break;
            case "EnemyTrigger1":
                Debug.Log("touched trigger " + other.gameObject.name);
                LevelManager.instance.activateAISpawn[1] = true;
                other.gameObject.SetActive(false);
                break;
            case "EnemyTrigger2":
                Debug.Log("touched trigger " + other.gameObject.name);
                LevelManager.instance.activateAISpawn[2] = true;
                other.gameObject.SetActive(false);
                break;
            case "EnemyTrigger3":
                Debug.Log("touched trigger " + other.gameObject.name);
                LevelManager.instance.activateAISpawn[3] = true;
                other.gameObject.SetActive(false);
                break;
            case "EnemyTrigger4":
                Debug.Log("touched trigger " + other.gameObject.name);
                LevelManager.instance.activateAISpawn[4] = true;
                other.gameObject.SetActive(false);
                break;
            case "EnemyTrigger5":
                Debug.Log("touched trigger " + other.gameObject.name);
                LevelManager.instance.activateAISpawn[5] = true;
                other.gameObject.SetActive(false);
                break;
            case "EnemyTrigger6":
                Debug.Log("touched trigger " + other.gameObject.name);
                LevelManager.instance.activateAISpawn[6] = true;
                other.gameObject.SetActive(false);
                break;

            case "Door0":

                if (LevelManager.instance.stageCompleted[0])
                {
                    LevelManager.instance.doorsToBeOpened[0].GetComponent<Doors>().OpenDoor();
                }

                break;
            case "Door1":

                if (LevelManager.instance.stageCompleted[1])
                {
                    LevelManager.instance.doorsToBeOpened[1].GetComponent<Doors>().OpenDoor();
                }

                break;
            case "Door2":

                if (LevelManager.instance.stageCompleted[2])
                {
                    LevelManager.instance.doorsToBeOpened[2].GetComponent<Doors>().OpenDoor();
                }

                break;
            case "Door3":

                if (LevelManager.instance.stageCompleted[3])
                {
                    LevelManager.instance.doorsToBeOpened[3].GetComponent<Doors>().OpenDoor();
                }

                break;
            case "Door4":

                if (LevelManager.instance.stageCompleted[4])
                {
                    LevelManager.instance.doorsToBeOpened[4].GetComponent<Doors>().OpenDoor();
                }

                break;
            case "Door5":

                if (LevelManager.instance.stageCompleted[5])
                {
                    LevelManager.instance.doorsToBeOpened[5].GetComponent<Doors>().OpenDoor();
                }

                break;
            case "Door6":

                if (LevelManager.instance.stageCompleted[6])
                {
                    LevelManager.instance.doorsToBeOpened[6].GetComponent<Doors>().OpenDoor();
                }

                break;

            case "Portal":
                Debug.Log("LevelsCleared, portal : " + GameGlobalVariablesManager.LevelsCleared);
                LevelManager.instance.ClosePortal();
                GameGlobalVariablesManager.OnLevelCleared();
                SavedData.Inst.SaveAllData();
                Application.LoadLevel(GameGlobalVariablesManager.LevelSelection);
                break;

            case "WallLightLayer":
                Debug.Log("WallLightLayer: " + transform.position + other.gameObject.name);
                Idle();
                playerBehaviour = PlayerBehaviour.IDLE;
                break;

            default:
                break;
        }
    }
Esempio n. 51
0
    void Update()
    {
        animatorStateInfo = characterAnimator.GetCurrentAnimatorStateInfo(0);

        if (!GameGlobalVariablesManager.isKnifeThrow)
        {
            if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
            {
                target = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                hit = Physics2D.Raycast(target, Vector2.zero);

                if (hit.collider != null)
                {
                    layerName = LayerMask.LayerToName(hit.collider.gameObject.layer);
                    Debug.Log(layerName);
                    switch (layerName)
                    {
                        case "AI":
                            selectedObject = hit.collider.gameObject;
                            distanceToAttack = initialSpeed;
                            if (selectedObject.GetComponent<AIComponent>().selectionMarker != null)
                            {
                                selectedObject.GetComponent<AIComponent>().selectionMarker.SetActive(true);
                            }
                            touchPos = selectedObject.transform.position;
                            isAttack = true;
                            nextAttackTimer = 0;
                            playerBehaviour = PlayerBehaviour.MOVE;
                            break;

                        case "Objects":
                            selectedObject = hit.collider.gameObject;
                            distanceToAttack = intialDistanceToAttack / 2;
                            touchPos = selectedObject.transform.position;

                            Debug.Log("clicked on Objects");
                            isAttack = true;
                            nextAttackTimer = 0;
                            playerBehaviour = PlayerBehaviour.MOVE;
                            break;

                        case "WallLightLayer":
                            touchPos = this.transform.position;
                            isAttack = false;
                            nextAttackTimer = 0;
                            break;

                        case "AreaLock":
                            touchPos = this.transform.position;
                            isAttack = false;
                            nextAttackTimer = 0;
                            break;

                        case "Player":
                            touchPos = this.transform.position;
                            isAttack = false;
                            nextAttackTimer = 0;
                            break;

                        default:
                            touchPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                            if (selectedObject != null)
                            {
                                //ponz.2do null check
                                //selectedObject.GetComponent<AIComponent>().selectionMarker.SetActive (false);

                                if (selectedObject.GetComponent<AIComponent>() != null)
                                    selectedObject.GetComponent<AIComponent>().selectionMarker.SetActive(false);
                            }
                            isAttack = false;
                            nextAttackTimer = 0;
                            playerBehaviour = PlayerBehaviour.MOVE;
                            break;
                    }// end of switch
                } //if  collider != null
                else
                {
                    touchPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                    Debug.Log("collider = null =" + touchPos);
                    if (selectedObject != null)
                    {
                        // ponz.2do
                        if (selectedObject.GetComponent<AIComponent>() != null)
                            selectedObject.GetComponent<AIComponent>().selectionMarker.SetActive(false);
                        selectedObject = null;
                    }
                    playerBehaviour = PlayerBehaviour.MOVE;
                }
            }

            if (GameGlobalVariablesManager.isPlayerSpin)
            {
                canSpin = true;
                sTime -= Time.deltaTime;
                Spin();
            }
        }
        else
        {
            if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject() && !canThrow)
            {
                distanceToThrow = initialDistanceToThrow;
                target = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                hit = Physics2D.Raycast(target, Vector2.zero);

                if (hit.collider != null)
                {
                    layerName = LayerMask.LayerToName(hit.collider.gameObject.layer);
                    Debug.Log(layerName);

                    switch (layerName)
                    {
                        case "AI":
                            selectedObject = hit.collider.gameObject;
                            if (selectedObject.GetComponent<AIComponent>().selectionMarker != null)
                            {
                                selectedObject.GetComponent<AIComponent>().selectionMarker.SetActive(true);
                            }
                            touchPos = selectedObject.transform.position;
                            canThrow = true;
                            CoolOffKnife = 3.0f;
                            playerBehaviour = PlayerBehaviour.MOVEANDTHROW;
                            break;

                        case "Objects":
                            selectedObject = hit.collider.gameObject;
                            touchPos = selectedObject.transform.position;
                            Debug.Log("touch pos is generated");
                            canThrow = true;
                            playerBehaviour = PlayerBehaviour.MOVEANDTHROW;
                            break;

                        case "WallLightLayer":
                            touchPos = this.transform.position;
                            break;

                        case "AreaLock":
                            touchPos = this.transform.position;
                            break;

                        default:
                            touchPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                            if (selectedObject != null)
                            {
                                selectedObject.GetComponent<AIComponent>().selectionMarker.SetActive(false);
                            }
                            playerBehaviour = PlayerBehaviour.MOVEANDTHROW;
                            break;
                    }
                }
                else
                {
                    touchPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                    if (selectedObject != null)
                    {
                        selectedObject.GetComponent<AIComponent>().selectionMarker.SetActive(false);
                        selectedObject = null;
                    }
                    playerBehaviour = PlayerBehaviour.MOVEANDTHROW;
                }
            }
        }

        switch (playerBehaviour)
        {
            case PlayerBehaviour.IDLE:
                break;

            case PlayerBehaviour.MOVE:
                if (!GameGlobalVariablesManager.isFireBallThrown)
                    MoveTowardsPoint();
                break;

            case PlayerBehaviour.MOVEANDTHROW:
                MoveTowardsThrowPoint();
                break;

            case PlayerBehaviour.ATTACK:
                break;

            case PlayerBehaviour.REACT:
                break;
        }

        if (GameGlobalVariablesManager.isFireBallThrown)
        {
            fTimer -= Time.deltaTime;
            ShowFireBallCircle();
        }

        PlayerDead();

        Debug.DrawLine(wallColliderObj.transform.position, touchPos, Color.red, 0.5f);
        if (CoolOffTime < 0)
        {
            CoolOffTime = 10.0f;
            UpdateAttackCombo(0);
        }
        else
        {
            CoolOffTime -= Time.deltaTime;
        }

        if (canThrow)
        {
            CoolOffKnife -= Time.deltaTime;
            if (CoolOffKnife < 0)
            {
                CoolOffKnife = 3.0f;
                canThrow = false;
            }
        }
    }
 void Start()
 {
     //Specify reference location, script is componnent of Object tagged "Player"
     playerInfo = GameObject.FindWithTag("Player").GetComponent<PlayerBehaviour>();
     //gameObject.SetActive (true);
 }
 // Use this for initialization
 void Start()
 {
     playerInfo = gameObject.GetComponent<PlayerBehaviour>();
 }
Esempio n. 54
0
	void OnLevelWasLoaded (int level)
	{
		// When the DayScene(1) is loaded, get the MainCharacter
		if (level == SceneManager.GetSceneByName ("DayScene").buildIndex) {
			mainCharacter = GameObject.Find ("MainCharacter");

			if (mainCharacter == null) {
				Debug.LogError ("No 'MainCharacter' was found in the scene " + level + ".");
			} else {
				playerBehave = mainCharacter.GetComponent<PlayerBehaviour> ();

				if (playerBehave == null) {
					Debug.LogError ("No PlayerBehaviour script was found in the 'mainCharacter'.");
				}
			}
		}
	}
Esempio n. 55
0
    // Use this for initialization
    void Start()
    {
        inputManager = InputManager.Instance;

        gameManager = gameObject.GetComponent<GameManager>();
        spawnManager = gameObject.GetComponent<EnemySpawnManager>();

        mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();

        inputManager.Mouse_Moved += ProcessMousePosition;

        playerInfo = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerBehaviour>();

        //Get the HUD, populate player health and game stats
        HUDBar = mainCamera.transform.FindChild("HUDBar").gameObject;

        for (int i = 0; i < playerInfo.Health; i++)
        {
            Vector3 newBlipLocalPosition = new Vector3(healthBlipStartPos.x, healthBlipStartPos.y, 0);

            GameObject newHealthBlip = GameObject.Instantiate(Resources.Load("Prefabs/Health_Blip") ) as GameObject;

            float blipWidth = newHealthBlip.GetComponent<SpriteRenderer>().bounds.extents.x * 2;

            newBlipLocalPosition.x += blipWidth * i;

            newHealthBlip.transform.parent = HUDBar.transform;

            newHealthBlip.transform.localPosition = newBlipLocalPosition;

            healthBlips.Add(newHealthBlip);
        }

        waveNumDisplay[0] = HUDBar.transform.FindChild("Wave_Ones").gameObject;
        waveNumDisplay[1] = HUDBar.transform.FindChild("Wave_Tens").gameObject;
        waveNumDisplay[2] = HUDBar.transform.FindChild("Wave_Hundreds").gameObject;

        enemyNumDisplay[0] = HUDBar.transform.FindChild("Enemies_Ones").gameObject;
        enemyNumDisplay[1] = HUDBar.transform.FindChild("Enemies_Tens").gameObject;
        enemyNumDisplay[2] = HUDBar.transform.FindChild("Enemies_Hundreds").gameObject;

        moneyNumDisplay[0] = HUDBar.transform.FindChild("Money_Ones").gameObject;
        moneyNumDisplay[1] = HUDBar.transform.FindChild("Money_Tens").gameObject;
        moneyNumDisplay[2] = HUDBar.transform.FindChild("Money_Hundreds").gameObject;

        crosshair = GameObject.Find("Crosshair");

        gameOverPanel = HUDBar.transform.FindChild("GameOverPanel").gameObject;
        scoreSubmissionStatus = gameOverPanel.transform.FindChild("SubmissionStatus").gameObject;
        gameOverScoreDisplay[0] = gameOverPanel.transform.FindChild("Score_Ones").gameObject;
        gameOverScoreDisplay[1] = gameOverPanel.transform.FindChild("Score_Tens").gameObject;
        gameOverScoreDisplay[2] = gameOverPanel.transform.FindChild("Score_Hundreds").gameObject;

        numberSprites = Resources.LoadAll<Sprite>("Sprites/UI/UI_Numbers");

        ShowHideGameOver(false);

        shopManager = HUDBar.transform.FindChild("ShopDisplay").GetComponent<ShopManager>();
        shopManager.ShowHideShop(false, false);

        breakTimePanel = HUDBar.transform.FindChild("WaveTimeDisplay").gameObject;
        breakTimeDisplay[0] = breakTimePanel.transform.FindChild("Seconds_Ones").gameObject;
        breakTimeDisplay[1] = breakTimePanel.transform.FindChild("Seconds_Tens").gameObject;

        gameManager.GameOverEvent += OnGameOver;
    }
Esempio n. 56
0
    void LevelGenerator()
    {
        GameObject tmp;
        m_levelStaticsObj = new ArrayList();
        m_levelPosition = new ArrayList();
        m_levelPacdot = new ArrayList();

        for (int i = 0; i < LevelMap.Length; ++i)
        {
            int x = (i % (int) m_lenght.x);
            int y = (i / (int)m_lenght.x * (-1));

            float fX = x - (m_lenght.x / 2) + 0.5f;
            float fY = y + (m_lenght.y / 2) - 0.5f;

            m_levelPosition.Add(new Vector2(fX, fY));

            switch (m_levelMap[i])
            {
                case 1:
                    tmp = (GameObject) GameObject.Instantiate(Resources.Load("CornerTopLeft"));
                    tmp.transform.position = new Vector2(fX, fY);
                    m_levelStaticsObj.Add(tmp);
                    break;

                case 2:
                    tmp = (GameObject) GameObject.Instantiate(Resources.Load("CornerTopRight"));
                    tmp.transform.position = new Vector2(fX, fY);
                    m_levelStaticsObj.Add(tmp);
                    break;

                case 3:
                    tmp = (GameObject) GameObject.Instantiate(Resources.Load("CornerDownLeft"));
                    tmp.transform.position = new Vector2(fX, fY);
                    m_levelStaticsObj.Add(tmp);
                    break;

                case 4:
                    tmp = (GameObject) GameObject.Instantiate(Resources.Load("CornerDownRight"));
                    tmp.transform.position = new Vector2(fX, fY);
                    m_levelStaticsObj.Add(tmp);
                    break;

                case 5:
                    tmp = (GameObject) GameObject.Instantiate(Resources.Load("HorizontalWall"));
                    tmp.transform.position = new Vector2(fX, fY);
                    m_levelStaticsObj.Add(tmp);
                    break;

                case 6:
                    tmp = (GameObject) GameObject.Instantiate(Resources.Load("VerticalWall"));
                    tmp.transform.position = new Vector2(fX, fY);
                    m_levelStaticsObj.Add(tmp);
                    break;

                case 7:
                    tmp = (GameObject) GameObject.Instantiate(Resources.Load("ClosedDoorHorizontal"));
                    tmp.transform.position = new Vector2(fX, fY);
                    m_levelStaticsObj.Add(tmp);
                    break;

                case 8:
                    tmp = (GameObject) GameObject.Instantiate(Resources.Load("ClosedDoorVertical"));
                    tmp.transform.position = new Vector2(fX, fY);
                    m_levelStaticsObj.Add(tmp);
                    break;

                case 9:
                    tmp = (GameObject) GameObject.Instantiate(Resources.Load("Pacdot"));
                    tmp.transform.position = new Vector2(fX, fY);
                    m_levelPacdot.Add(tmp);
                    break;
            }
        }

        tmp = (GameObject)GameObject.Instantiate(Resources.Load("Player"));
        m_player = tmp.GetComponent<PlayerBehaviour>();
    }
Esempio n. 57
0
 // Use this for initialization
 void Start()
 {
     player = playerObj.GetComponent<PlayerBehaviour>();
     col = gameObject.GetComponent<Collider>();
 }
Esempio n. 58
0
 void Start()
 {
     player = GetComponent<PlayerBehaviour>();
     pData = GetComponent<PlayerData>();
     pInput = GetComponent<PlayerInput>();
     controller = GetComponent<CharacterController>();
     myTransform = transform;
     rayDistance = controller.height * .5f + controller.radius;
     slideLimit = controller.slopeLimit - .1f;
     jumpTimer = antiBunnyHopFactor;
 }
Esempio n. 59
0
    // Use this for initialization
    void Start()
    {
        fShootCooldownReset = fShootCooldown;

        playerBehaviour = gameObject.GetComponent<PlayerBehaviour>();
    }
Esempio n. 60
0
 public PlayerState(PlayerFSM fsm, PlayerBehaviour character)
 {
     this.fsm = fsm;
     this.character = character;
 }