예제 #1
0
 // Start is called before the first frame update
 void Start()
 {
     oldPanelColor = new Vector4(0, 0, 0, 0.7f);
     panel.GetComponent <Image>().color = new Vector4(0, 0, 0, 0);
     UIPlayerHP = playerHealth.GetComponent <UIPlayerHealth>();
     UIPanel    = panel.GetComponent <Image>();
 }
예제 #2
0
 // Start is called before the first frame update
 void Start()
 {
     defaultCrosshairColor = crosshair.GetComponent <RawImage>().color;
     playerHP       = UIPlayerHealth.Get();
     crosshairImage = crosshair.GetComponent <RawImage>();
     ammo           = 5;
 }
예제 #3
0
 // Start is called before the first frame update
 void Start()
 {
     playerPoints = PlayerPoints.Get();
     playerHp     = UIPlayerHealth.Get();
     rig          = player.GetComponent <Rigidbody>();
     force        = -7000;
 }
예제 #4
0
 // Start is called before the first frame update
 void Start()
 {
     ball.GetComponent <MeshRenderer>().enabled   = false;
     ball.GetComponent <SphereCollider>().enabled = false;
     playerHP              = UIPlayerHealth.Get();
     playerPoints          = PlayerPoints.Get();
     crosshairImage        = crosshair.GetComponent <RawImage>();
     defaultCrosshairColor = crosshair.GetComponent <RawImage>().color;
     ammo = 10;
 }
예제 #5
0
    private void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
            return;
        }

        instance = this;
        DontDestroyOnLoad(gameObject);
    }
예제 #6
0
    // Start is called before the first frame update
    void Start()
    {
        playerPoints          = PlayerPoints.Get();
        defaultColor          = transform.gameObject.GetComponent <MeshRenderer>().material.color;
        GhostHunterProjectile = ball.gameObject.GetComponent <GhostHunter_ball>();
        ghostModel            = transform.gameObject.GetComponent <MeshRenderer>();
        rig          = player.GetComponent <Rigidbody>();
        playerStatus = playerHp.GetComponent <UIPlayerHealth>();

        movementTimer = 5;
    }
 void Awake()
 {
     instance = this;
 }
예제 #8
0
    // Update is called once per frame
    void FixedUpdate()
    {
        //if (m_pathArray[0]!= null)
        //{
        //    for (int i = 0; i < MonsterPathFinding.stackSize - 1; i++)
        //    {
        //        temp1.Set(m_pathArray[i].x, 1, m_pathArray[i].y);
        //        temp2.Set(m_pathArray[i + 1].x, 1, m_pathArray[i + 1].y);
        //        Debug.DrawLine(temp1, temp2, Color.blue);
        //    }
        //    startPosition.Set(m_pathArray[currentWayPoint].x, 1, m_pathArray[currentWayPoint].y);
        //    endPosition.Set(m_pathArray[currentWayPoint + 1].x, 1, m_pathArray[currentWayPoint + 1].y);
        //    newDirection = (endPosition - startPosition);

        //    rotation = Quaternion.LookRotation(newDirection);
        //    transform.rotation = Quaternion.Lerp(transform.rotation, rotation, 0.25f);
        //    //gameObject.transform.(endPosition);
        //    //gameObject.transform.Translate(Vector3.forward);

        //    //float x = newDirection.x;
        //    //float y = newDirection.y;
        //    //float rotationAngle = Mathf.Atan2(y, x) * 180 / Mathf.PI;
        //    //transform.rotation = Quaternion.AngleAxis(rotationAngle, Vector3.forward);

        //    pathLength = Vector3.Distance(startPosition, endPosition);
        //    totalTimeForPath = pathLength / speed;//路径上总共需要花费的时间
        //    currentTimeOnPath = Time.time - lastWaypointSwitchTime;
        //    transform.position = Vector3.Lerp(startPosition, endPosition, currentTimeOnPath / totalTimeForPath);
        //    //RotateIntoMoveDirection();
        //    if (transform.position == endPosition)
        //    {
        //        if (currentWayPoint < MonsterPathFinding.stackSize - 2)
        //        {
        //            currentWayPoint++;
        //            lastWaypointSwitchTime = Time.time;
        //            // TODO: Rotate into move direction
        //        }
        //    }
        //}

        //for (int i = 0; i < MonsterPathFinding.stackSize - 1; i++)
        //{
        //    temp1.Set(m_ListPath[i].x, 1, m_ListPath[i].y);
        //    temp2.Set(m_ListPath[i + 1].x, 1, m_ListPath[i + 1].y);
        //    Debug.DrawLine(temp1, temp2, Color.blue);
        //}

        for (int i = 4; i >= 0; i--)
        {
            if (Time.time < statusTime[i])
            {
                if (i == 4)
                {
                    changewalkSpeed(0);
                }
                else
                {
                    if (isSlowDown == 1)
                    {
                        changewalkSpeed(speed * (1 - TowerElemInfo.slowdownDegree[i]));
                    }
                }
                break;
            }
            else if (Time.time > statusTime[i])
            {
                walkSpeed = speed;
            }
        }

        //if (isPause)
        //{
        //    isPause = false;
        //    Pause(1);
        //}

        ////暂停后恢复原来速度
        //if (Time.time - pauseStartTime >= pauseTime)
        //{
        //    changeSpeed(walkSpeed);
        //}

        //for (int i = 0; i < AStar.m_ListPath.Count - 1; i++)
        //{
        //    if (m_ListPath[i + 1].X == -1)
        //    {
        //        i++;
        //        continue;
        //    }
        //    temp1.Set(m_ListPath[i].X, 1, m_ListPath[i].Y);
        //    temp2.Set(m_ListPath[i + 1].X, 1, m_ListPath[i + 1].Y);
        //    Debug.DrawRay(temp1, Vector3.up, Color.red);
        //    Debug.DrawLine(temp1, temp2, Color.blue);
        //}
        //startPosition.Set(m_ListPath[currentWayPoint].X, 1, m_ListPath[currentWayPoint].Y);

        ////碰到x,y为-1,-1的点时,把list下标往后移两个单位
        //if (m_ListPath[currentWayPoint + 1].X == -1)
        //{
        //    currentWayPoint += 2;
        //    Vector3 temp = transform.position;
        //    temp.Set(m_ListPath[currentWayPoint].X, 1, m_ListPath[currentWayPoint].Y);
        //    transform.position = temp;
        //}
        endPosition.Set(m_ListPath[currentWayPoint + 1].X, 1, m_ListPath[currentWayPoint + 1].Y);
        newDirection = (endPosition - transform.position);

        rotation           = Quaternion.LookRotation(newDirection);
        transform.rotation = Quaternion.Lerp(transform.rotation, rotation, 0.25f);
        //gameObject.transform.(endPosition);
        //gameObject.transform.Translate(Vector3.forward);

        //float x = newDirection.x;
        //float y = newDirection.y;
        //float rotationAngle = Mathf.Atan2(y, x) * 180 / Mathf.PI;
        //transform.rotation = Quaternion.AngleAxis(rotationAngle, Vector3.forward);

        //pathLength = Vector3.Distance(startPosition, endPosition);
        //totalTimeForPath = pathLength / speed;//路径上总共需要花费的时间
        //currentTimeOnPath = Time.time - lastWaypointSwitchTime;
        //transform.position = Vector3.Lerp(startPosition, endPosition, currentTimeOnPath / totalTimeForPath);
        //RotateIntoMoveDirection();
        rb.velocity = transform.forward * walkSpeed;
        if (Vector3.Distance(transform.position, endPosition) <= 0.5f)
        {
            if (currentWayPoint < AStar.m_ListPath.Count - 2)
            {
                currentWayPoint++;
                //lastWaypointSwitchTime = Time.time;
                // TODO: Rotate into move direction
            }
            else
            {
                walkSpeed = Mathf.Lerp(walkSpeed, 0, 0.25f);
                Destroy(this.gameObject);
                UIPlayerHealth.TakeHealth(UIGameLevel.level * 2);

                //walkSpeed = speed;
            }
        }
    }