예제 #1
0
    // Use this for initialization
    void Start()
    {
        GameObject player = GameObject.FindGameObjectWithTag("Player");

        playervars = player.GetComponent <PlayerVars> ();
        ScrollWeapon(0);         //sets current weapon without moving weapon.
    }
예제 #2
0
    // Use this for initialization
    private void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(gameObject);
        }

        //Get Player previously selected team
        string PlayerTeamPath = Application.streamingAssetsPath + "/PlayerTeam.json";

        if (File.Exists(PlayerTeamPath))
        {
            string     PlayerTeamString = File.ReadAllText(PlayerTeamPath);
            JSONObject PlayerTeam       = JSON.Parse(PlayerTeamString) as JSONObject;
            PlayerGold = PlayerTeam["PlayerGold"];
            for (int index = 0; index < 3; ++index)
            {
                SelectedTeamNames[index] = PlayerTeam["SelectedTeam"].AsArray[index];
            }
        }
    }
예제 #3
0
    // Use this for initialization
    void Start () {
        vars = gameObject.GetComponent<PlayerVars>();

        joyAim = new Vector3(1.0f, 0.0f, 0);
        canShoot = true;
        reload = 0.0f;
    }
예제 #4
0
    // Use this for initialization
    void Start()
    {
        waitingOnInput = false;

        inventory = this.gameObject.GetComponentInChildren <Inventory>();
        vars      = this.GetComponent <PlayerVars>();
    }
예제 #5
0
    void Start()
    {
        //Инициализация
        anim = GetComponent <Animation>();
        rig  = GetComponent <Rigidbody>();
        VARS = GetComponent <PlayerVars>();

        rig.isKinematic = !GetComponent <NetworkView>().isMine;

        //Дабы не случилось форсмажоров
        transform.position = new Vector3(transform.position.x, 51.4f, transform.position.z);

        Physics.IgnoreLayerCollision(10, 10, true);
        Physics.IgnoreLayerCollision(10, 11, true);

        charS = CharS.Idle;

        damage_timer = Time.time;

        //PATHFINDING
        self = GetComponent <RTSObject>();
        UpdateCurrentTile();

        DontDestroyOnLoad(this);
    }
 public PlayerHorizontalMovementAction(Rigidbody player, PlayerVars vars)
     : base(KeyCode.Space)
 {
     this.playerRigidbody = player;
     this.playervars = vars;
     this.floorMask = LayerMask.GetMask ("Floor");
 }
예제 #7
0
 void Start()
 {
     obj   = GetComponent <Controller>();
     var   = GetComponent <PlayerVars>();
     run   = Time.time - 10f;
     press = Time.time - 10f;
 }
예제 #8
0
    public void attack(PlayerVars other)
    {
        int deal = doDamage();

        other.takeHit(deal);
        takeHit(other.hitBack());
    }
예제 #9
0
 //Call in LevelManager
 public void UpdateFromPlayerVar(PlayerVars p)
 {
     CurrentHealth = p.playerHealth;
     MaxHealth     = p.playerMaxHealth;
     SetPlayerName(p.playerName);
     SetHairdo(p.hairSprite, p.hairColor);
     UpdateSkinColor(p.skinTint);
 }
예제 #10
0
    // Use this for initialization
    void Start ()
   {
        vars = gameObject.GetComponent<PlayerVars>();
        rb = gameObject.GetComponent<Rigidbody2D>();
        animator = gameObject.GetComponent<Animator>();

        isHit = false;
   }
예제 #11
0
 void Awake()
 {
     GameObject player = GameObject.FindGameObjectWithTag ("Player");
     globalvars = player.GetComponent<PlayerVars> ();
     floorMask = LayerMask.GetMask ("Floor");
     anim = GetComponent<Animator> ();
     playerRigidbody = GetComponent<Rigidbody> ();
     leapAction = new PlayerHorizontalMovementAction (playerRigidbody, globalvars);
     jumpAction = new PlayerVerticalMovementAction (playerRigidbody, globalvars);
 }
예제 #12
0
    void Awake()
    {
        GameObject player = GameObject.FindGameObjectWithTag("Player");

        globalvars      = player.GetComponent <PlayerVars> ();
        floorMask       = LayerMask.GetMask("Floor");
        anim            = GetComponent <Animator> ();
        playerRigidbody = GetComponent <Rigidbody> ();
        leapAction      = new PlayerHorizontalMovementAction(playerRigidbody, globalvars);
        jumpAction      = new PlayerVerticalMovementAction(playerRigidbody, globalvars);
    }
예제 #13
0
    private void Awake()
    {
        if (_instance != null && _instance != this)
        {
            Destroy(this.gameObject);
        }
        else
        {
            _instance = this;
        }                              //destroys any player inventorys that are not the orignal one

        DontDestroyOnLoad(gameObject); //makes this stay acrossed level loads so vars stay consistant
    }
예제 #14
0
 // Use this for initialization
 void Start()
 {
     GameObject player = GameObject.FindGameObjectWithTag ("Player");
     playervars = player.GetComponent<PlayerVars> ();
     ScrollWeapon (0);//sets current weapon without moving weapon.
 }
 public void RegisterDeath(PlayerVars player)
 {
     if(!PhotonNetwork.isMasterClient)		//howd you get here?
     {
         Debug.LogError("Client made way into RegisterDeath()!");
         return;
     }
     if(player.CanAttack)
     {
         m_playersCanAttack.Remove(player.PlayerName);
         if(m_playersCanAttack.Count == 0)
             EndGame(GameResources.WIN_GROUP_VICTORY);
     }
 }
예제 #16
0
 public PlayerVerticalMovementAction(Rigidbody player, PlayerVars vars) : base(KeyCode.E)
 {
     this.playerRigidbody = player;
     this.playervars      = vars;
 }
예제 #17
0
 protected virtual void Start()
 {
     GameObject player = GameObject.FindGameObjectWithTag ("Player");
     playervars = player.GetComponent<PlayerVars> ();
 }
 public PlayerHorizontalMovementAction(Rigidbody player, PlayerVars vars) : base(KeyCode.Space)
 {
     this.playerRigidbody = player;
     this.playervars      = vars;
     this.floorMask       = LayerMask.GetMask("Floor");
 }
 public PlayerVerticalMovementAction(Rigidbody player, PlayerVars vars)
     : base(KeyCode.E)
 {
     this.playerRigidbody = player;
     this.playervars = vars;
 }
예제 #20
0
    protected virtual void Start()
    {
        GameObject player = GameObject.FindGameObjectWithTag("Player");

        playervars = player.GetComponent <PlayerVars> ();
    }
예제 #21
0
 // Use this for initialization
 void Start()
 {
     // Linking them together.
     playerVars = playerGameObject.GetComponent <PlayerVars>();
 }
예제 #22
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
            }
        }
    }