Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        PlayerMoving moving = Player.GetComponent <PlayerMoving>();
        float        Bpl    = moving.BombPressed;

        if (Bpl > 0)
        {
            gaugeObject.GetComponent <Image>().fillAmount = Mathf.Clamp01(Bpl / moving.status.BombTime_SP) * 0.5f
                                                            + Mathf.Clamp01((Bpl - moving.status.BombTime_SP) / (moving.status.BombTime_EX - moving.status.BombTime_SP)) * 0.5f;
        }
        gaugeObject.transform.parent.gameObject.SetActive(moving.bombpressed);
        Text.SetActive(moving.bombpressed);
        if (Bpl < moving.status.BombTime_SP)
        {
            Text.GetComponent <Text>().text = "LV1";
        }
        else if (Bpl < moving.status.BombTime_EX)
        {
            Text.GetComponent <Text>().text = "LV2";
        }
        else
        {
            Text.GetComponent <Text>().text = "LV3";
        }

        GetComponent <RectTransform>().position
            = RectTransformUtility.WorldToScreenPoint(Camera.main, Player.transform.position);
    }
    // Start is called before the first frame update
    void Start()
    {
        GameObject gameControllerObject = GameObject.FindGameObjectWithTag("GameController");

        if (gameControllerObject != null)
        {
            score = gameControllerObject.GetComponent <Score>();
        }
        if (score == null)
        {
            Debug.Log("Cannot find 'GameController' script");
        }

        GameObject cameraFollowObject = GameObject.FindGameObjectWithTag("MainCamera");

        if (cameraFollowObject != null)
        {
            cameraFollow = cameraFollowObject.GetComponent <CameraFollow>();
        }
        if (cameraFollowObject == null)
        {
            Debug.Log("Cannot find 'cameraFollow' script");
        }

        playerCombo  = GetComponent <PlayerCombo>();
        rigidbody2D  = GetComponent <Rigidbody2D>();
        gravity      = rigidbody2D.gravityScale;
        playerMoving = GetComponent <PlayerMoving>();

#if UNITY_IOS || UNITY_ANDROID || UNITY_EDITOR //if current platform is mobile,
        screenWidth = Screen.width;
#endif
    }
Ejemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     player          = GameObject.Find("Player");
     PlayerAttribute = GameObject.Find("Player").GetComponent <PlayerAttribute>();
     PlayerMoving    = GameObject.Find("Player").GetComponent <PlayerMoving>();
     levle           = 1;
 }
Ejemplo n.º 4
0
 public static byte[] PlayerMovingPack(PlayerMoving dataStruct)
 {
     byte[] data = new byte[56];
     for (int i = 0; i < 56; i++)
     {
         data[i] = 0;
     }
     Array.Copy(BitConverter.GetBytes(dataStruct.PacketType), 0, data, 0, 4);
     //Console.WriteLine("packetType: " + dataStruct.packetType.ToString());
     Array.Copy(BitConverter.GetBytes(dataStruct.NetID), 0, data, 4, 4);
     //Console.WriteLine("netID: " + dataStruct.netID.ToString());
     Array.Copy(BitConverter.GetBytes(dataStruct.CharacterState), 0, data, 12, 4);
     // Console.WriteLine("Charstate: " + dataStruct.characterState.ToString());
     Array.Copy(BitConverter.GetBytes(dataStruct.PlantingTree), 0, data, 20, 4);
     //Console.WriteLine("plantingTree: " + dataStruct.plantingTree.ToString());
     Array.Copy(BitConverter.GetBytes(dataStruct.X), 0, data, 24, 4);
     //Console.WriteLine("x: " + dataStruct.x.ToString());
     Array.Copy(BitConverter.GetBytes(dataStruct.Y), 0, data, 28, 4);
     // Console.WriteLine("y: " + dataStruct.y.ToString());
     Array.Copy(BitConverter.GetBytes(dataStruct.XSpeed), 0, data, 32, 4);
     // Console.WriteLine("XSpeed: " + dataStruct.XSpeed.ToString());
     Array.Copy(BitConverter.GetBytes(dataStruct.YSpeed), 0, data, 36, 4);
     //Console.WriteLine("PACKSPEED: " + BitConverter.ToString(BitConverter.GetBytes(dataStruct.XSpeed)));
     // Console.WriteLine("YSpeed: " + dataStruct.YSpeed.ToString());
     Array.Copy(BitConverter.GetBytes(dataStruct.PunchX), 0, data, 44, 4);
     // Console.WriteLine("punchX: " + dataStruct.punchX.ToString());
     Array.Copy(BitConverter.GetBytes(dataStruct.PunchY), 0, data, 48, 4);
     // Console.WriteLine("punchY: " + dataStruct.punchY.ToString());
     return(data);
 }
Ejemplo n.º 5
0
        public async Task <IActionResult> Move(int clickedTileId)
        {
            string userId      = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            User   currentUser = await _userManager.FindByIdAsync(userId);

            Player       currentPlayer = _db.Players.FirstOrDefault(player => player.Name == currentUser.UserName);
            BoardPiece   currentPiece  = _db.BoardPieces.FirstOrDefault(piece => piece.PlayerHere == true);
            BoardPiece   clickedPiece  = _db.BoardPieces.FirstOrDefault(piece => piece.Id == clickedTileId);
            PlayerMoving firstMove     = new PlayerMoving(0, 0, null, 0, 0, 0, 0, 0, false);

            if (currentPlayer.AvailableMoves > 0)
            {
                currentPlayer.AvailableMoves -= 1;
                if (currentPiece.Id == (clickedPiece.Id + 1) || currentPiece.Id == (clickedPiece.Id - 1) || currentPiece.Id == (clickedPiece.Id + 10) || currentPiece.Id == (clickedPiece.Id - 10))
                {
                    currentPiece.PlayerHere = false;
                    currentPlayer.AddResource(clickedPiece.ResourceType);
                    PlayerMoving successMove = new PlayerMoving(currentPiece.Id, clickedPiece.Id, clickedPiece.ResourceType, currentPlayer.Wood, currentPlayer.Gold, currentPlayer.Metal, currentPlayer.Stone, currentPlayer.AvailableMoves, true);
                    firstMove = successMove;
                    //currentPiece.ResourceHere = false;
                    //currentPiece.ResourceType = "None";
                    clickedPiece.PlayerHere = true;
                    //currentPlayer.AddResource(clickedPiece.ResourceType);
                    clickedPiece.ResourceHere = false;
                    clickedPiece.ResourceType = "None";

                    //_db.Entry(currentPlayer).State = EntityState.Modified;
                    _db.Entry(currentPiece).State = EntityState.Modified;
                    _db.Entry(clickedPiece).State = EntityState.Modified;
                    _db.SaveChanges();
                }
            }

            return(Json(firstMove));
        }
Ejemplo n.º 6
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Ejemplo n.º 7
0
    private void Start()
    {
        Enemy.isExistTarget = true;
        AdventureController.isPlayerAlive = true;

        //shield = GameObject.FindGameObjectWithTag("Shield");
        //쉴드도 착용 쉴드에 따라서 인스턴시에이트 해줘야지
        //RectTransform shieldTransform = shield.GetComponent<RectTransform>();
        //shieldTransform.anchoredPosition = new Vector2(-500,0);
        // 쉴드 위치 잡아줌

        //hpText = GameObject.FindGameObjectWithTag("Player").transform.Find("HP").GetComponent<Text>();
        //find 사용 안 하고 인스펙터로 연결해줌

        //playerShooting = GameObject.Find("Player(Clone)").GetComponent<PlayerShooting>();
        playerShooting = this.GetComponent <PlayerShooting>();
        // Player(Clone) Fine 하던 거 this 로 찾아서 할당
        // 그런데 결국 Attack 에서 Find 써서 Player 클론을 찾아주고 있음
        // 그렇게 안 하면 palyerShooting 이 안 불림. 왠지 잘 모르겠네.
        // Start 에서 선언 안 해주면 Update 에서 에러가 남
        // 그렇다는 건 Awake Start Update 는 하나의 쓰레드로 묵여 있는 것일까?
        // Attack 처럼 내가 새로 만든 함수에선 Start 에서 선언해둔 메모리가 참조가 되지 않는다.
        // 이 부분에 대한 공부가 좀 더 필요할 듯.

        reloadSlider.SetActive(false);
        //playerImage = GameObject.FindGameObjectWithTag("Player").transform.Find("PlayerImage").GetComponent<Image>();

        playerMoving = this.GetComponent <PlayerMoving>();

        StartCoroutine(ActivatePlayer());
    }
Ejemplo n.º 8
0
 private void Start()
 {
     player          = GameObject.Find("Player");
     timer           = 0;
     PlayerMoving    = GameObject.Find("Player").GetComponent <PlayerMoving>();
     PlayerAttribute = GameObject.Find("Player").GetComponent <PlayerAttribute>();
     reducetime      = 0;
 }
Ejemplo n.º 9
0
    public static PlayerMoving instance; //unique instance of the script for easy access to the script

    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        this.fixedDeltaTime = Time.fixedDeltaTime;
    }
Ejemplo n.º 10
0
    // Use this for initialization

    private void OnTriggerEnter2D(Collider2D collision)
    {
        bool isHit = true;

        // Debug.Log(((int)Mathf.Pow(2, collision.gameObject.layer) & PassThrough.value));
        if (((int)Mathf.Pow(2, collision.gameObject.layer) & PassThrough.value)
            == (int)Mathf.Pow(2, collision.gameObject.layer) ||
            (collision.transform.tag == "Enemy" && tag == "Enemy's Bullet") ||
            (collision.transform.tag == "Player" && tag == "Player's Bullet"))
        {
            isHit = false;
        }
        if (collision.transform.tag == "Enemy" && tag == "Player's Bullet")
        {
            EnemyStatus status;
            if (collision.GetComponent <EnemyHitComp_RefTo>() != null)
            {
                status = collision.transform.GetComponent <EnemyHitComp_RefTo>().Status;
                GameObject.Find("Status").GetComponent <StatusComp>().TargetedEnemy = status.gameObject;
                status.status.hp -= FirePower;
            }
        }

        if (collision.transform.tag == "Player" && tag == "Enemy's Bullet")
        {
            PlayerMoving status = collision.transform.parent.GetComponent <PlayerMoving>();
            PlayerMoving Player = collision.transform.parent.GetComponent <PlayerMoving>();
            if (status.status.InvisTime == 0)
            {
                Player.Damaged      = true;
                status.status.Life -= FirePower;
                Player.gameObject.GetComponent <Rigidbody2D>().velocity =
                    Mathf.Sign(Player.transform.localScale.x) * Vector2.left * FirePower * 4
                    +
                    Vector2.up * FirePower * 2;
                isHit = true;
            }
        }
        if (collision.tag == "Shutters" && tag == "Enemy's Bullet")
        {
            isHit = true;
        }
        if (isHit == true)
        {
            Destroy(gameObject);
            if (HitEffect != null)
            {
                Instantiate(HitEffect, transform.position, Quaternion.Euler(0, 0, 0));
            }
        }
        if (eventstart != null)
        {
            string output = eventstart.gameObject.SaveHierarchyToMemory().GetString();
            Load.HierarchyFromMemory(output.GetBytes(), new GameObject(eventstart.name));
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     player = GameObject.FindGameObjectWithTag("Player");
     if (player != null)
     {
         playerMoving  = player.GetComponent <PlayerMoving>();
         playerControl = player.GetComponent <PlayerControl>();
     }
     gameOver = GetComponent <GameOver>();
 }
Ejemplo n.º 12
0
    void Awake()
    {
        Player          = GameObject.Find("Player");
        PlayerStatus    = Player.GetComponent <PlayerMoving>();
        text            = GetComponent <Text>();
        MPOrbsResources = Resources.Load("UI/MpsCharge") as GameObject;
        gauge           = new OrbGauge[Mathf.CeilToInt(PlayerStatus.status.SpiritMax)];

        Orbsize = MPOrbsResources.GetComponent <GaugeSettles>().Gauges.GetComponent <Image>().sprite.bounds.size;
    }
Ejemplo n.º 13
0
 private void Awake()
 {
     if (Instance != null)
     {
         Destroy(gameObject);
         return;
     }
     Instance = this;
     DontDestroyOnLoad(gameObject);
 }
Ejemplo n.º 14
0
    void Start()
    {
        //初始化
        spriteRenderer = GetComponent <SpriteRenderer>();
        curAlpha       = 0.5f;
        player         = GameObject.Find("Player").GetComponent <PlayerMoving>();

        PlayerAttribute = GameObject.Find("Player").GetComponent <PlayerAttribute>();
        JumpNumber      = GameObject.Find("JUMP").GetComponent <JumpNumber>();
    }
Ejemplo n.º 15
0
 // Start is called before the first frame update
 void Start()
 {
     health = 100;
     GS     = FindObjectOfType <GameSystem>();
     body   = GetComponent <Rigidbody2D>();
     PM     = GetComponent <PlayerMoving>();
     PE     = GetComponent <PlayerEffects>();
     bar    = FindObjectOfType <HPBar>();
     bar.updateHealth(health);
 }
Ejemplo n.º 16
0
        public static async Task UpdateDoor(ENetPeer peer, int foreground, int x, int y, string text)
        {
            try
            {
                PlayerMoving sign = new PlayerMoving
                {
                    PacketType     = 0x3,
                    CharacterState = 0x0,
                    X            = x,
                    Y            = y,
                    PunchX       = x,
                    PunchY       = y,
                    NetID        = -1,
                    PlantingTree = foreground
                };
                await SendPacketRaw(4, PlayerMovingPack(sign), 56, 0, peer);

                int    hmm = 8; int text_len = text.Length; int lol = 0; int wut = 5; int yeh = hmm + 3 + 1; int idk = 15 + text_len;
                int    is_locked = 0; int bubble_type = 1; int ok = 52 + idk; int kek = ok + 4; int yup = ok - 8 - idk; int magic = 56;
                int    wew = ok + 5 + 4; int wow = magic + 4 + 5; int four = 4;
                byte[] data = new byte[kek]; byte[] p = new byte[wew];
                for (int i = 0; i < kek; i++)
                {
                    data[i] = 0;
                }
                Array.Copy(BitConverter.GetBytes(wut), 0, data, 0, four);
                Array.Copy(BitConverter.GetBytes(hmm), 0, data, yeh, four);
                Array.Copy(BitConverter.GetBytes(x), 0, data, yup, 4);
                Array.Copy(BitConverter.GetBytes(y), 0, data, yup + 4, 4);
                Array.Copy(BitConverter.GetBytes(idk), 0, data, 4 + yup + 4, four);
                Array.Copy(BitConverter.GetBytes(foreground), 0, data, magic, 2);
                Array.Copy(BitConverter.GetBytes(lol), 0, data, four + magic, four);
                Array.Copy(BitConverter.GetBytes(bubble_type), 0, data, magic + 4 + four, 1);
                Array.Copy(BitConverter.GetBytes(text_len), 0, data, wow, 2);
                Array.Copy(Encoding.ASCII.GetBytes(text), 0, data, 2 + wow, text_len);
                Array.Copy(BitConverter.GetBytes(is_locked), 0, data, ok, four);
                Array.Copy(BitConverter.GetBytes(four), 0, p, 0, four);
                Array.Copy(data, 0, p, four, kek);
                foreach (ENetPeer currentPeer in Peers)
                {
                    if (currentPeer.State != ENetPeerState.Connected)
                    {
                        continue;
                    }
                    if (peer.InWorld(currentPeer))
                    {
                        currentPeer.Send(p, 0, ENetPacketFlags.Reliable);
                    }
                }
            }
            catch
            {
                Console.WriteLine("error in updatedoor");
            }
        }
Ejemplo n.º 17
0
 private void OnValidate()
 {
     if (!mover)
     {
         mover = GetComponentInChildren <PlayerMoving>();
     }
     if (!debugText)
     {
         debugText = GetComponentInChildren <DebugText>();
     }
 }
Ejemplo n.º 18
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
     _camera = Camera.main;
 }
    void ConfiguratingLocationLevel(ConfigurationData configurationData)
    {
        LocationLevelGenerator.GenerateLocationLevel(configurationData.locationLevelSettings,
                                                     configurationData.locationLevelProgressionType, configurationData.spawnResourcesStrategy);

        ExpLevelCounter.InitializeThis(configurationData.requiredForLevelExperience, configurationData.changingExpCoeff);

        CrystallPickable.ExpCrystallValue = configurationData.crystallValue;

        GoldPickable.GoldValue = configurationData.goldValue;

        PlayerMoving.InitializeThis(configurationData.speed, configurationData.angularSpeed);
    }
Ejemplo n.º 20
0
    private void Awake()
    {
        //initialize this first before assigned to object
        MaxVelocity = 1f;
        SpeedChange = 8f;
        JumpForce   = 5f;

        MyRigidbody = GetComponent <Rigidbody>();

        movementSM = new MovementStateMachine();

        MovingState  = new PlayerMoving(this, movementSM);
        JumpingState = new PlayerJump(this, movementSM);
    }
Ejemplo n.º 21
0
 private void Awake()
 {
     // Setting up the references.
     // Only one player....
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
     _camera = Camera.main;
 }
Ejemplo n.º 22
0
    public void Damaging(GameObject Player)
    {
        PlayerMoving player = Player.GetComponent <PlayerMoving>();

        if (player.status.InvisTime == 0)
        {
            player.Damaged      = true;
            player.status.Life -= DamageNum;
            Player.gameObject.GetComponent <Rigidbody2D>().velocity =
                Mathf.Sign(Player.transform.localScale.x) * Vector2.left * Impact * 4
                +
                Vector2.up * Impact * 2;
        }
    }
Ejemplo n.º 23
0
        public static async Task SendNothingHappened(ENetPeer peer, int x, int y)
        {
            PlayerMoving data = new PlayerMoving
            {
                NetID        = (peer.Data as Player).NetID,
                PacketType   = 0x8,
                PlantingTree = 0
            };

            data.NetID  = -1;
            data.X      = x;
            data.Y      = y;
            data.PunchX = x;
            data.PunchY = y;
            await SendPacketRaw(4, PlayerMovingPack(data), 56, 0, peer);
        }
Ejemplo n.º 24
0
    private void Awake()
    {
        //настраиваем ссылку на самого себя, если в переменной пусто то добавляем ссыку на этот скрипт
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            //но если на сцене уже есть объекты с этим скриптом, то мы их просто удаляем
            Destroy(gameObject);
        }

        //настроим ссылку на нашу камеру
        _camera = Camera.main;
    }
Ejemplo n.º 25
0
    // Use this for initialization
    void Start()
    {
        bgmObject = GameObject.Find("Background_Music");
        bgm       = bgmObject.GetComponent <AudioSource>();

        backObject = GameObject.Find("Background01");
        backGround = backObject.GetComponent <SpriteRenderer>();

        camera = GameObject.Find("-Main Camera");
        cM     = camera.GetComponent <CameraController>();

        //dialogUI = GameObject.Find("DialogUI");
        p = player.GetComponent <PlayerMoving>();

        popUpChapter(onGoingChapter);
        //popUpCity(1);
    }
Ejemplo n.º 26
0
    //const float k_GroundedRadius = .2f;



    private void Start()
    {
        player = gameObject.GetComponentInParent <PlayerMoving>();
        box    = gameObject.GetComponentInParent <CircleCollider2D>();
    }
Ejemplo n.º 27
0
 // Start is called before the first frame update
 void Start()
 {
     Hp     = GetComponentInParent <Player>();
     isJump = GetComponentInParent <PlayerMoving>();
     isAtk  = GetComponentInParent <PlayerComBat>();
 }
Ejemplo n.º 28
0
 void Awake()
 {
     playerMoving = gameObject.GetComponent<PlayerMoving>();
 }
Ejemplo n.º 29
0
 private void Start()
 {
     lastPosition  = transform.position;
     playerControl = GetComponent <PlayerControl>();
     playerMoving  = GetComponent <PlayerMoving>();
 }
Ejemplo n.º 30
0
 public void Execute(PlayerMoving playerMoving)
 {
     playerMoving.GoRight();
 }
Ejemplo n.º 31
0
    // Use this for initialization
    void Start()
    {
        /*
         * // デフォルトの肌の色の数値を代入する
         * SaveColor = new Color(1.0f, 0.78f, 0.55f, 1.0f);
         * // 色が変わった状態でHumanが無くなるとMaterialが変更されてままになるので生成時に初期色入れておく
         * Hand_R.color = SaveColor;
         * Hand_L.color = SaveColor;
         * Calf_R.color = SaveColor;
         * Calf_L.color = SaveColor;
         */
        m_state = EState.Init;
        m_hitReceivePlayerID = PlayerID;

        InputName[0] = "Horizontal_Player";
        InputName[1] = "Vertical_Player";
        InputName[2] = "A_Player";
        InputName[3] = "B_Player";
        InputName[4] = "X_Player";
        InputName[5] = "Y_Player";

        myInputManager = FindObjectOfType <MyInputManager>();
        if (myInputManager == null)
        {
            Debug.LogError("MyInputManagerがシーンに存在しません");
        }

        m_crushPointManager = FindObjectOfType <CrushPointManager>();
        if (m_crushPointManager == null)
        {
            Debug.LogError("CrushPointManagerがシーンに存在しません。");
        }

        // 手足伸ばすスクリプト
        m_extendAndShrink = GetComponent <PlayerExtendAndShrink>();
        if (m_extendAndShrink == null)
        {
            Debug.LogError("PlayerExtendAndShrinkをアタッチしてください。");
        }
        // 移動処理スクリプト
        m_moving = GetComponent <PlayerMoving>();
        if (m_moving == null)
        {
            Debug.LogError("PlayerMovingをアタッチしてください。");
        }
        // プレイヤーカメラスクリプト
        P_Camera = GetComponent <PlayerCamera>();
        if (P_Camera == null)
        {
            Debug.LogError("PlayerCameraをアタッチしてください。");
        }
        // 地面とのRayの処理スクリプト
        if (m_ray == null)
        {
            Debug.LogError("PlayerRayをセットしてください。");
        }
        // パーツスケールのスクリプト
        m_parts = GetComponent <PartsScale>();
        if (m_parts == null)
        {
            Debug.LogError("PartsScaleをアタッチしてください。");
        }


        if (!DebugModeGame.GetProperty().m_debugMode)
        {
            return;
        }
        // デバッグモードONの時の設定
        if (DebugModeGame.GetProperty().m_debugPlayerEnable)
        {
            m_state = EState.Idle;
        }
        if (DebugModeGame.GetProperty().m_controllerDisable)
        {
            myInputManager.joysticks[m_playerID - 1] = m_playerID;
        }
    }