Exemplo n.º 1
0
    /// <summary>
    /// beforeFirst -> beforeSecond
    /// </summary>
    void ShotFirst()
    {
        // check mouse position
        RaycastHit hitinfo;

        if (!Physics.Raycast(maincam.ScreenPointToRay(Input.mousePosition), out hitinfo, 200.0f, Constants.groundLayerMask))
        {
            // mouse clicked wrong thing
            return;
        }
        // function
        projectileObj.SetActive(true);
        projectileTr.position = masterTr.position;
        Vector3 direction = hitinfo.point - masterTr.position;

        direction.y          = 0;
        direction            = (direction == Vector3.zero) ? Vector3.forward : direction;
        this.shotDestination = direction.normalized * this.skillRange + masterTr.position;

        // state change
        this.sequence = Seq.beforeSecond;
        // frame function update
        this.FrameFunction     = ControlFirstShot;
        this.LateFrameFunction = Nothing;
        //
        this.skillRangeObj.SetActive(false);
    }
Exemplo n.º 2
0
 void CancelSkillRange()
 {
     // state change
     this.state    = State.idle;
     this.sequence = Seq.notActive;
     // frame function update
     this.FrameFunction = Nothing;
     // function
     skillRangeObj.SetActive(false);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Skill notActive -> beforeFirst
 /// </summary>
 void ActiveSkill()
 {
     // state change
     this.state    = State.ActiveNow;
     this.sequence = Seq.beforeFirst;
     // frame function update
     this.FrameFunction     = Nothing;
     this.LateFrameFunction = SkillRangeFollow;
     // function
     skillRangeObj.SetActive(true);
     skillRangeObj.transform.position = masterTr.position;
 }
Exemplo n.º 4
0
 // Start is called before the first frame update
 void Start()
 {
     // initial this
     masterTr          = GetComponent <Transform>();
     FrameFunction     = Nothing;
     LateFrameFunction = Nothing;
     maincam           = Camera.main;
     // instantiate prefab
     skillRangeObj = Instantiate <GameObject>(skillRangePrefab);
     skillRangeObj.SetActive(false);
     projectileObj = Instantiate <GameObject>(ProjectilePrefab);
     projectileObj.SetActive(false);
     // initialize sub object
     skillRangeTr = skillRangeObj.GetComponent <Transform>();
     projectileTr = projectileObj.GetComponent <Transform>();
 }
Exemplo n.º 5
0
    void ControlSecondShot()
    {
        Vector3 joeyVector = masterTr.position - projectileTr.position;

        if (Vector3.Dot(joeyVector, this.shotDirection) <= 0)
        {
            // following end
            // set variable
            this.leftDistance = skillRange;
            // state change
            this.sequence = Seq.secondShotFollowingEnd;
            // frame function update
            this.FrameFunction     = ControlShotNotFollowing;
            this.LateFrameFunction = Nothing;
            return;
        }

        projectileTr.position += this.shotDirection * this.ProjectileVelocity_second * Time.deltaTime;
    }
Exemplo n.º 6
0
    void ShotSecond()
    {
        // check mouse position
        RaycastHit hitinfo;

        if (!Physics.Raycast(maincam.ScreenPointToRay(Input.mousePosition), out hitinfo, 200.0f, Constants.groundLayerMask))
        {
            // mouse clicked wrong thing
            return;
        }
        // function
        Vector3 direction = hitinfo.point - projectileTr.position;

        direction.y        = 0;
        direction          = (direction == Vector3.zero) ? Vector3.forward : direction;
        this.shotDirection = direction.normalized;
        // state change
        this.sequence = Seq.secondShotFollowing;
        // frame function update
        this.FrameFunction     = ControlSecondShot;
        this.LateFrameFunction = Nothing;
    }
Exemplo n.º 7
0
    void ControlShotNotFollowing()
    {
        Vector3 projectileMoving = this.shotDirection * this.ProjectileVelocity_second * Time.deltaTime;

        if (this.leftDistance < 0.01f)
        {
            // all Q skill End
            // state change
            this.sequence = Seq.notActive;
            this.state    = State.idle; // have to modify as waiting
            // frame function update
            this.FrameFunction     = Nothing;
            this.LateFrameFunction = Nothing;
            // disable object
            this.projectileObj.SetActive(false);
        }
        if (this.leftDistance < projectileMoving.magnitude)
        {
            projectileMoving = this.shotDirection * leftDistance;
        }

        projectileTr.position += projectileMoving;
        this.leftDistance     -= projectileMoving.magnitude;
    }