コード例 #1
0
    void throwBall()
    {
        if (this.kidType == 3)
        {
            GlobalsHolder globalVariable = GameObject.Find("GlobalVariableHolders").GetComponent <GlobalsHolder>();
            Vector3       ball1Movement  = new Vector3(globalVariable.getKidTypeInfo(kidType).attackRangeUnit *GlobalsHolder.ballMoveSpeed *(this.playerGroup == 1 ? 1 : -1), 0, globalVariable.getKidTypeInfo(kidType).attackRangeUnit *GlobalsHolder.ballMoveSpeed);
            GameObject    ball1          = Instantiate(Resources.Load("Prefabs/Ball", typeof(GameObject))) as GameObject;
            ball1.transform.position = this.transform.position + new Vector3(0.0f, 0.5f, 0.37f);
            ball1.GetComponent <BallController>().init(this.playerGroup, this.kidType, ball1Movement, this.gameObject);

            Vector3    ball2Movement = new Vector3(globalVariable.getKidTypeInfo(kidType).attackRangeUnit *GlobalsHolder.ballMoveSpeed *(this.playerGroup == 1 ? 1 : -1), 0, globalVariable.getKidTypeInfo(kidType).attackRangeUnit *GlobalsHolder.ballMoveSpeed * -1);
            GameObject ball2         = Instantiate(Resources.Load("Prefabs/Ball", typeof(GameObject))) as GameObject;
            ball2.transform.position = this.transform.position + new Vector3(0.0f, 0.5f, -0.37f);
            ball2.GetComponent <BallController>().init(this.playerGroup, this.kidType, ball2Movement, this.gameObject);
        }
        // else if (this.kidType == 4)
        // {
        //   GlobalsHolder globalVariable = GameObject.Find("GlobalVariableHolders").GetComponent<GlobalsHolder>();
        //   Vector3 ballMovement = new Vector3(globalVariable.getKidTypeInfo(kidType).attackRangeUnit * GlobalsHolder.ballMoveSpeed * (this.playerGroup == 1 ? 1 : -1), 0, 0);
        //   GameObject ball = Instantiate(Resources.Load("Prefabs/Ball", typeof(GameObject))) as GameObject;
        //   ball.transform.position = this.transform.position + new Vector3(0.25f * (this.playerGroup == 1 ? 1 : -1), 0.5f, 0.0f);
        //   ball.gameObject.GetComponent<Rigidbody>().useGravity = false;
        //   ball.GetComponent<BallController>().init(this.playerGroup, this.kidType, ballMovement);
        // }
        else
        {
            GlobalsHolder globalVariable = GameObject.Find("GlobalVariableHolders").GetComponent <GlobalsHolder>();
            Vector3       ballMovement   = new Vector3(globalVariable.getKidTypeInfo(kidType).attackRangeUnit *GlobalsHolder.ballMoveSpeed *(this.playerGroup == 1 ? 1 : -1), 0, 0);
            GameObject    ball           = Instantiate(Resources.Load("Prefabs/Ball", typeof(GameObject))) as GameObject;
            ball.transform.position = this.transform.position + new Vector3(0.25f * (this.playerGroup == 1 ? 1 : -1), 0.5f, 0.0f);
            ball.GetComponent <BallController>().init(this.playerGroup, this.kidType, ballMovement, this.gameObject);
        }
    }
コード例 #2
0
    public void init(int playerGroup, int kidType, int laneNum)
    {
        GlobalsHolder globalVariable = GameObject.Find("GlobalVariableHolders").GetComponent <GlobalsHolder>();

        this.isDead      = false;
        this.reachedGoal = false;
        this.playerGroup = playerGroup;
        this.kidType     = kidType;
        if (this.kidType == 2)
        {
            this.invisible = true;
        }
        this.gameObject.tag = (playerGroup == 1 ? "P1Kid" : "P2Kid");
        this.movementSpeed  = globalVariable.getKidTypeInfo(this.kidType).moveSpeedUnit *GlobalsHolder.kidMoveSpeed;
        this.laneNum        = laneNum;
    }