Пример #1
0
    // void Awake(){
    //     animator = myTransform.Find ("PlayerModel").GetComponent<Animator> ();
    // }
    // Use this for initialization
    void Start()
    {
        Debug.Log(GetComponent <NetworkIdentity>().playerControllerId);
        //Cache the attached components for better performance and less typing
        healthSlider = GetComponentInChildren <Slider>();
        rigidBody    = GetComponent <Rigidbody>();
        myTransform  = transform;
        joystick     = FindObjectOfType <FloatingJoystick>();
        firePrefab   = GameObject.FindGameObjectWithTag("fire");
        //animator = myTransform.Find ("PlayerModel").GetComponent<Animator> ();
        animator = GetComponent <Animator> ();
        if (isLocalPlayer)
        {
            GameObject.FindGameObjectWithTag("bombControl").GetComponent <Button>().onClick.AddListener(this.OnClickBomb);
            GameObject.FindGameObjectWithTag("bananaControl").GetComponent <Button>().onClick.AddListener(this.CmdDropBanana);
            GameObject.FindGameObjectWithTag("dartControl").GetComponent <Button>().onClick.AddListener(this.shoot);
            GameObject.FindGameObjectWithTag("invincibleControl").GetComponent <Button>().onClick.AddListener(this.toImmune);

            GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraFollow>().player = gameObject;
        }
        hpBarTransform = transform.Find("Canvas").GetComponent <RectTransform>();
        hpBarRotation  = hpBarTransform.rotation;
        var myColor = GetComponent <Prototype.NetworkLobby.PlayerInfo>().m_color;
        var i       = Math.Max(Array.FindIndex(Prototype.NetworkLobby.LobbyPlayer.Colors, color => color == myColor), 0) % playerMats.Length;

        GetComponent <SkinnedMeshRenderer>().material = playerMats[i];
    }
Пример #2
0
 void BuildMobile()
 {
     if (joyStick == null)
     {
         joyStick = FindObjectOfType <FloatingJoystick>();
     }
     joyInput = new Vector2(joyStick.Horizontal, joyStick.Vertical);
 }
Пример #3
0
 void Start()
 {
     rigidbody2d = GetComponent <Rigidbody2D>();
     animator    = GetComponent <Animator>();
     health      = PlayerPrefs.GetFloat("player_health", 3f);
     UIManager.instance.UpdateHealth(health);
     joystick = FindObjectOfType <FloatingJoystick>();
 }
Пример #4
0
    private void Start()
    {
        maxHealth = 150;

        rb           = GetComponent <Rigidbody2D>();
        rend         = GetComponent <SpriteRenderer>();
        leftJoystick = GameObject.Find("LeftJoystick").GetComponent <FloatingJoystick>();
    }
Пример #5
0
 protected override void StartOverride()
 {
     base.StartOverride();
     _weapon              = GetComponentInChildren <WeaponSystems>().gameObject;
     _camera              = GetComponentInChildren <Camera>().transform;
     _joystick            = LevelController.instance.joystick;
     _finishLineTransform = LevelController.instance.finishLine;
     _initialPosition     = transform.position;
 }
Пример #6
0
 void Start()
 {
     _rigidbody  = GetComponent <Rigidbody>();
     _transform  = transform;
     _playerData = GetComponent <PlayerData>();
     _joystick   = FindObjectOfType <FloatingJoystick>();
     EventManager.Instance.AddListener(EventType.JoystickOn, (type, sender, o) => { _isJoystick = true; });
     EventManager.Instance.AddListener(EventType.JoystickOff, (type, sender, o) => { _isJoystick = false; });
 }
Пример #7
0
    void Start()
    {
        joystick        = FindObjectOfType <FloatingJoystick>();
        cachedTransform = transform;
#if UNITY_EDITOR && !UNITY_REMOTE
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;
#endif
    }
Пример #8
0
 void Start()
 {
     //anim = GetComponent<Animator>();
     playerRB2D          = GetComponent <Rigidbody2D>();
     playerRB2D.velocity = new Vector2(0, 0);//not needed??
     theJoystick         = FindObjectOfType <FloatingJoystick>();
     playerAnimator      = GetComponent <Animator>();
     health = maxHealth;
 }
Пример #9
0
 private void Start()
 {
     m_gameManager    = GetComponent <GameManager>();
     m_joystick       = m_joystickGameObject.GetComponent <FloatingJoystick>();
     m_settingManager = FindObjectOfType <SettingManager>();
     if (m_debug)
     {
         Debug.Log(m_settingManager);
     }
 }
Пример #10
0
 public void SetUpInputController(PlayerControllerView player, FloatingJoystick JoyStick, Button fire_Bomb)
 {
     if (this.fire_Bomb == null)
     {
         this.fire_Bomb = fire_Bomb;
         this.fire_Bomb.onClick.AddListener(FireBomb);
     }
     this.JoyStick = JoyStick;
     this.player   = player;
 }
Пример #11
0
    void Start()
    {
        firing = false;

        pistolBullet = Resources.Load("PistolBullet") as GameObject;

        rightJoystick = GameObject.Find("RightJoystick").GetComponent <FloatingJoystick>();

        direction = new Vector3(1, 0, 0);
    }
Пример #12
0
    private void Awake()
    {
        PV      = GetComponent <PhotonView>();
        buildPC = Resources.Load <BoolVariable>("BuildPC");

        if (buildPC.Value == false)
        {
            joyStick = FindObjectOfType <FloatingJoystick>();
        }
    }
Пример #13
0
 private void Start()
 {
     if (floatingJoystick == null)
     {
         floatingJoystick = FindObjectOfType <FloatingJoystick>();
     }
     if (gameObject.GetComponent <CharacterController>() == null)
     {
         controller = gameObject.AddComponent <CharacterController>();
     }
 }
Пример #14
0
 private void FindJoystick()
 {
     FloatingJoystick[] joysticks = FindObjectsOfType <FloatingJoystick>();
     foreach (FloatingJoystick joystick in joysticks)
     {
         if (joystick.gameObject.name == "Move Joystick")
         {
             _moveJoystick = joystick;
         }
     }
 }
Пример #15
0
    void Start()
    {
        instance    = this;
        playerAgent = GetComponent <UnityEngine.AI.NavMeshAgent>();

        //find things in scene
        joystick  = GameObject.Find("FloatingJoystick").GetComponent <FloatingJoystick>();
        joystick2 = GameObject.Find("FloatingJoystick2").GetComponent <FloatingJoystick>();
        joystick3 = GameObject.Find("FloatingJoystick3").GetComponent <FloatingJoystick>();

        MainCamera = Camera.main.transform;
    }
Пример #16
0
    /*
     * protected float cameraAngleY;
     * public float cameraAngleSpeed = 0.1f;
     *
     * protected float CameraPosY;
     * public float cameraPosSpeed = 0.1f;
     */

    // Start is called before the first frame update

    public void Awake()
    {
        if (photonView.isMine)
        {
            TurnJoystick  = FindObjectOfType <FloatingJoystick>();
            TouchField    = FindObjectOfType <FixedTouchField>();
            VcamScriptLoc = FindObjectOfType <CinemachineFreeLook>();
            CarControl    = GetComponent <CarUserControl>();
            fixedTouch    = FindObjectOfType <FixedTouchField>();
            FireButton    = FindObjectOfType <Button>();
            rb            = GetComponent <Rigidbody>();
        }
    }
Пример #17
0
 private void Awake()
 {
     // get the car controller
     if (photonView.isMine)
     {
         m_Car         = GetComponent <CarController>();
         TurnJoystick  = FindObjectOfType <FloatingJoystick>();
         fixedTouch    = FindObjectOfType <FixedTouchField>();
         VcamScriptLoc = FindObjectOfType <CinemachineFreeLook>();
         fixedTouch    = FindObjectOfType <FixedTouchField>();
         FireButton    = FindObjectOfType <Button>();
     }
 }
Пример #18
0
    public virtual void Awake()
    {
        if (!photonView.IsMine)
        {
            return;
        }

        // Get the components from the Hierachy
        joystick           = GameObject.FindGameObjectWithTag("UI").transform.GetChild(0).GetComponent <FloatingJoystick>();
        fielOfView         = GameObject.FindGameObjectWithTag("Fov").transform.GetComponent <FieldOFView>();
        animatorController = GetComponent <AnimatorController>();

        rb = GetComponent <Rigidbody2D>();
    }
Пример #19
0
    void SubscibeToUI()
    {
/*        Debug.Log("IsMine " + photonView.IsMine);*/
        if ((photonView.IsMine || !PhotonNetwork.IsConnectedAndReady))
        {
            LeftJoystick = FindObjectOfType <FloatingJoystick>();
            TouchField   = FindObjectOfType <FixedTouchField>();

/*            if(!Loader.Instance.curentScene == roomScene)
 *          {
 *              JumpButton = FindObjectOfType<FixedButton>();
 *          }*/
        }
    }
    void Awake()
    {
        LeftJoystickGO  = GameObject.FindGameObjectWithTag("Left_Joystick");
        RightJoystickGO = GameObject.FindGameObjectWithTag("Right_Joystick");

        FloatingJoystickLeft  = LeftJoystickGO.GetComponent <FloatingJoystick>();
        FloatingJoystickRight = RightJoystickGO.GetComponent <FloatingJoystick>();

        Player = new Player()
        {
            LeftJoystick          = LeftJoystickGO.GetComponent <Joystick>(),
            RightJoystick         = RightJoystickGO.GetComponent <Joystick>(),
            CurrentHealth         = 100f,
            StartingHealth        = 100f,
            HealthSlider          = healthSlider,
            Speed                 = m_speed,
            PlayerRigidbody       = GetComponent <Rigidbody>(),
            Movement              = movement,
            PlayerTransform       = transform,
            NoAimZoneRadius       = 0.2f,
            FirePoint             = m_firePoint,
            FirePointDistance     = 1.15f,
            Projectile            = m_projectile,
            FireRate              = 1f,
            Canvas_HUD            = m_Canvas_HUD,
            Canvas_Attack_HUD     = m_Canvas_Attack_HUD,
            Offset_hud            = m_Canvas_HUD.position - transform.position,
            Offset_attack_hud     = m_Canvas_Attack_HUD.position - transform.position,
            ScaleSpeed            = 1f,
            AimMaxScale           = 10f,
            AimStartingScale      = m_Canvas_Attack_HUD_Aim.localScale,
            Canvas_Attack_HUD_Aim = m_Canvas_Attack_HUD_Aim,
            OrbitRadius           = 1f,
            IsDead                = false,
            NormalAttack          = new NormalAttack
            {
                SpeedOfAttack = 6f,
                Damage        = 200f,
                Range         = 8f,
                TagProjectile = "FriendlyFire"
            }
        };

        FloatingJoystickLeft.PlayerController  = this;
        FloatingJoystickRight.PlayerController = this;
        FloatingJoystickRight.NoAimZoneRadius  = Player.NoAimZoneRadius;
        FloatingJoystickRight.FireRate         = Player.FireRate;

        new DamageUIObserver(this);
    }
Пример #21
0
    // Use this for initialization
    void Start()
    {
        ResetScale();

        joyStick = GameObject.FindGameObjectWithTag("Joystick").GetComponent <FloatingJoystick>();
        joyStick.gameObject.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Screen.width);
        joyStick.gameObject.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Screen.height);

        gameInstance = GameObject.Find("playground").GetComponent <BreakerBehaviour>();

        otherBat = GameObject.Instantiate(otherBat);
        otherBat.transform.SetParent(transform);
        otherBat.transform.localPosition = new Vector3(0, this.minimalBatGap, 0);
    }
Пример #22
0
 private void FindJoystick()
 {
     FloatingJoystick[] joysticks = FindObjectsOfType <FloatingJoystick>();
     foreach (FloatingJoystick joystick in joysticks)
     {
         if (joystick.gameObject.name == "Rotate Joystick")
         {
             _rotateJoystick       = joystick;
             _joystickObjectRotate = _rotateJoystick.transform.GetChild(0).gameObject;
         }
         else if (joystick.gameObject.name == "Move Joystick")
         {
             _moveJoystick       = joystick;
             _joystickObjectMove = _moveJoystick.transform.GetChild(0).gameObject;
         }
     }
 }
Пример #23
0
    protected override void OnCreate()
    {
        RequireSingletonForUpdate <NetworkIdComponent>();                               // 创建一个组件对象准备传输数据
        RequireSingletonForUpdate <EnableMultiplayerPongGhostReceiveSystemComponent>(); // 创建一个组件对象准备接收对象

        // 这个是强耦合的方式生成并获取游戏对象
        var gameobject = Resources.Load <Canvas>("Canvas");

        gameobject = GameObject.Instantiate <Canvas>(gameobject);

        //joystick = Resources.Load<FixedJoystick>("Fixed Joystick");
        //joystick = Resources.Load<FixedJoystick>("Fixed Joystick");
        //joystick = GameObject.Instantiate<FixedJoystick>(joystick);
        //joystick.transform.SetParent(gameobject.transform);

        joystick = Resources.Load <FloatingJoystick>("Floating Joystick");
        joystick = GameObject.Instantiate <FloatingJoystick>(joystick);
        joystick.transform.SetParent(gameobject.transform);
    }
Пример #24
0
    void JoystickUpdate()
    {
        if (joyStick != null || buildPC.Value)
        {
            if (shouldTurn)
            {
                input = inputController.joyInput;

                if (input.x > 0 && !rightDir)
                {
                    rightDir             = true;
                    leftDir              = false;
                    ThrowObject.dirRight = false;

                    GiraOn(rightDir);
                }
                else if (input.x < 0 && !leftDir)
                {
                    leftDir             = true;
                    rightDir            = false;
                    ThrowObject.dirLeft = false;

                    GiraOn(rightDir);
                }
            }

            if (!PhotonNetwork.InRoom)
            {
                AtualizaPosicao(transform.position);
            }
            else
            {
                PV.RPC("AtualizaPosicao", RpcTarget.All, transform.position);
            }
        }
        else
        {
            joyStick = FindObjectOfType <FloatingJoystick>();
        }
    }
Пример #25
0
    public void Init()
    {
        if (PlayerPrefs.HasKey("ControlType"))
        {
            _moveInputType = (InputType)System.Enum.Parse(typeof(InputType), PlayerPrefs.GetString("ControlType"));
        }
        if (PlayerPrefs.HasKey("Sensitivity"))
        {
            _sensivity = PlayerPrefs.GetFloat("Sensitivity");
        }

        switch (_moveInputType)
        {
        case InputType.Keyboard:
            _moveInput = new KeyboradMoveInput();
            break;

        case InputType.Mouse:
            _moveInput = new MouseMoveInput(_transform);
            break;

        case InputType.DragMovement:
            DragMovement.Activate();
            _moveInput = (IMoveInput)DragMovement.Instance;
            break;

        case InputType.FloatingJoystick:
            FloatingJoystick.Activate();
            _moveInput = (IMoveInput)FloatingJoystick.Instance;
            break;

        case InputType.FixedJoystick:
            FixedJoystick.Activate();
            _moveInput = (IMoveInput)FixedJoystick.Instance;
            break;
        }

        PlayerPrefs.SetString("InputType", _moveInputType.ToString());
    }
Пример #26
0
        private void Start()
        {
            nameCharacter = Name.name;
            hitpoint      = Hitpoint.hitPoint;
            speedBullet   = SpeedBullet.speedBullet;
            demage        = Demage.demage;
            firingTimer   = FiringTimer.firingTimer;
            runTime       = RunTime.runTime;
            Agent.speed   = Speed.speed;
            fire          = false;
            BulletPrefab  = gameManager.bulletPrefab;
            GetComponent <MeshRenderer>().material.color = Color;
            HP.maxValue = Hitpoint.hitPoint;
            HP.value    = Hitpoint.hitPoint;

            if (Name.name == "Player")
            {
                JoystickPlayerExample joystick = this.gameObject.AddComponent <JoystickPlayerExample>();
                joystick.floatingJoystick = FindObjectOfType <FloatingJoystick>();
                joystick.rb      = this.GetComponent <Rigidbody>();
                joystick.speed   = Speed.speed;
                floatingJoystick = joystick.floatingJoystick;
            }
        }
 void Start()
 {
     touchJoystick = GameObject.FindGameObjectWithTag("TouchJoystick").GetComponent <FloatingJoystick>();
 }
Пример #28
0
 public void SetInput(FloatingJoystick js)
 {
     joystick = js;
 }
Пример #29
0
 void Start()
 {
     controller = GetComponent <PlayerController>();
     joystick1  = GameObject.FindWithTag("joystick1").GetComponent <FloatingJoystick>();
     joystick2  = GameObject.FindWithTag("joystick2").GetComponent <FloatingJoystick>();
 }
Пример #30
0
    //float rotationX = 0;

    private void Start()
    {
        joyStick = FindObjectOfType <FloatingJoystick>();
    }