Exemple #1
0
    private void Update()
    {
        agentPosition       = navMeshAgent.gameObject.transform.position;
        destinationPosition = positions[index].position;
        Debug.Log(curentState);

        switch (curentState)
        {
        case _State.patrol:
            if (!navMeshAgent.pathPending)
            {
                inputCommandObject.destination = destinationPosition;
            }
            if (Vector3.Distance(agentPosition, destinationPosition) < 2f)
            {
                curentState = _State.change_color;
            }
            break;

        case _State.change_color:
            Color color = new Color(UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value);
            inputCommandObject.desiredColor = color;
            curentState = _State.patrol;
            index++;
            index = index % numberPositions;
            break;

        case _State.follow_player:
            inputCommandObject.destination  = targetPlayer.transform.position;
            inputCommandObject.desiredColor = Color.red;
            break;
        }
    }
Exemple #2
0
        //also get called (on the projectile instance) when a projectile being hit by a beam
        public void Hit()
        {
            if (type == _SOType.Simple || type == _SOType.Homing)
            {
                HitEffect(thisT.position);
                if (!shootThrough)
                {
                    ProjectileHitDelay();
                }
                else
                {
                    state = _State.Shot;
                }

                if (Time.time - shootTime > destroyTime || travelledDistance > srcRange)
                {
                    ProjectileHitDelay();
                }
            }
            else if (type == _SOType.Point)
            {
                HitEffect(thisT.position + new Vector3(0, 0.2f, 0));
                ObjectPoolManager.Unspawn(thisObj);
            }
        }
Exemple #3
0
    private void Start()
    {
        aiState.alarmEvent.AddListener(AlarmTrigger);

        // iau parintele -> Enemy -> Enemy Controller
        GameObject parinte = transform.parent.gameObject;

        enemyController = parinte.GetComponent <EnemyController>();

        // iau playerul din scena,pozitia obiectului care se misca efectiv(Bot) si scriptableObject
        targetPlayer       = enemyController.player;
        inputCommandObject = enemyController.inputCommandObject;

        navMeshAgent = GetComponent <NavMeshAgent>();

        //initalizez curentstate cu initial State
        curentState = initialState;


        // culoare random
        Color color = new Color(UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value);

        inputCommandObject.desiredColor = color;


        if (!generateRandom)
        {
            GenerareManuala();
        }
        else
        {
            Debug.Log("teue");
            GenerareRandom();
        }
    }
 // estado 1
 void _G1_Prepare_Board()
 {
     _state = _State.G1_PREPARING_BOARD;
     Curtain._singleton._EarRequest(Curtain._Request.Activate);
     PanelBlock._singleton._EarRequest(PanelBlock._Request.Activate);
     DataManager._Singleton._Hand_Read_Game_Config_MySQL();
 }
        void _G3_Show_Objetives()
        {
            Debug.Log("Aqui3");

            _state = _State.G3_SHOWING_OBJETIVES;
            PanelBlock._singleton._EarRequest(PanelBlock._Request.Deactivate);
            Curtain._singleton._EarRequest(Curtain._Request.Deactivate);
        }
 void _G5_Run_Gameplay()
 {
     _state = _State.G5_RUNNING_GAMEPLAY;
     _aud_GameplaySong.Play();
     Countdown._singleton._EarRequest(Countdown._Request.Deactivate);
     PanelBlock._singleton._EarRequest(PanelBlock._Request.Deactivate);
     //GameplayManager._singleton._EarRequest(GameplayManager._Request.Start_Stage);
 }
 public void TransitionToState(_State nextState)
 {
     if (nextState == remainStats)
     {
         return;
     }
     currentState = nextState;
 }
Exemple #8
0
    void CheckDistanceToPlayer()
    {
        float curentdist = Vector3.Distance(targetPlayer.transform.position, transform.position);

        if (curentdist < distanceAttack)
        {
            curentState = _State.follow_player;
        }
    }
 void _G4_Show_Countdown()
 {
     _state = _State.G4_SHOWING_COUNTDOWN;
     //PanelBlock._singleton.Ear(PanelBlock._Request.Activate);
     PointsBar._singleton._EarRequest(PointsBar._Request.Show);
     HudLives._Singleton._EarRequest(HudLives._Request.Show_Timer);
     Countdown._singleton._EarRequest(Countdown._Request.Activate);
     Countdown._singleton._EarRequest(Countdown._Request.Start_Countdown_2s);
 }
Exemple #10
0
 //this ctor is used when copying or importing a workspace.
 //Deep-copies fields from f, except _model, _name, _id (generates new) and _testScriptId.
 FileNode(FilesModel model, FileNode f, string name)
 {
     _model            = model;
     _name             = name;
     _type             = f._type;
     _state            = f._state;
     _flags            = f._flags;
     _iconOrLinkTarget = f._iconOrLinkTarget;
     _id = _model.AddGetId(this);
 }
        void _G2_Raise_Curtain()
        {
            Debug.Log("Aqui3");

            _state = _State.G2_RAISING_CURTAIN;
            Curtain._singleton._EarRequest(Curtain._Request.Raise_Curtain);
            Objetives._singleton._EarRequest(Objetives._Request.Activate);
            Objetives._singleton._Hand_ShowObjetives();
            //Curtain._singleton._EarRequest(Curtain._Request.Raise_Curtain_2s);
        }
Exemple #12
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        //Debug.Log("colliding! - " + collision.transform);
        BugController bc = collision.transform.gameObject.GetComponent <BugController>();

        if (bc != null)
        {
            bc.KillMeWithoutAni();
        }
        else if (collision.gameObject.name == "butterfly_000")
        {
            Debug.Log("Eating Butterfly, Yum!");

            GameManager.gameManager.CoinsFeedback(collision.transform.position, 50);
            PowerUpManager.isPowerUpOnScene = false;
            CoccoonController.coccoonController.HideButterfly();

            // check goals
            foreach (Goal goal in PlayerController.player.level.goals.Values)
            {
                goal.checkEatButterfly();
            }
        }
        else if (collision.gameObject.name == "x2")
        {
            Debug.Log("Eating some x2, Yum!");
            PlayerController.player.BJamountSession *= 2;
            UIController.uIController.animateBJ();

            X2Controller.x2Controller.HideX2();

            // check goals
            foreach (Goal goal in PlayerController.player.level.goals.Values)
            {
                goal.checkEatX2();
            }
        }
        else
        {
            return;
        }

        if (_state.Equals(_State.ATTACK) || _state.Equals(_State.RETREAT))
        {
            _state = _State.ATTACK_BITE;
        }

        if (_state.Equals(_State.IDLE))
        {
            _state = _State.IDLE_BITE;
        }

        StopAllCoroutines();
        StartCoroutine(Bite());
    }
Exemple #13
0
    //public Microsoft.CodeAnalysis.DocumentId CaDocumentId;

    void _CtorMisc(string linkTarget)
    {
        if (!IsFolder)
        {
            if (!linkTarget.NE())
            {
                _state           |= _State.Link;
                _iconOrLinkTarget = linkTarget;
            }
        }
    }
Exemple #14
0
 //this ctor is used when copying or importing a workspace.
 //Deep-copies fields from f, except _model, _name, _id (generates new) and _testScriptId.
 FileNode(FilesModel model, FileNode f, string name)
 {
     _model = model;
     _SetName(name);
     _type       = f._type;
     _state      = f._state;
     _flags      = f._flags;
     _linkTarget = f._linkTarget;
     _icon       = f.CustomIconName;
     _id         = _model.AddGetId(this);
 }
    protected override void LateUpdate()
    {
        _State _state = new _State()
        {
            isFacingRight = isFacingRight,
        };

        currentInverseFrames += () => {
            isFacingRight = _state.isFacingRight;
        };
        base.LateUpdate();
    }
 void _G6_Extract_Statistics()
 {
     _state = _State.G6_EXTRACTING_STATISTICS;
     DataManager._Singleton._EarRequest(DataManager._Request.Activate);
     DataManager._Singleton._Hand_Save_Sattistics_MySQL
     (
         GameplayManagerNew._points,
         Traveler._Singleton._strUser,
         DataManager._Singleton._MySQL_levelTime,
         DataManager._Singleton._MySQL_itemValue
     );
 }
    protected override void LateUpdate()
    {
        _State state = new _State {
            ProcessTime = processTime
        };

        currentInverseFrames += () => {
            processTime = state.ProcessTime;
            particleSystem.Simulate(processTime, true);
        };
        base.LateUpdate();
    }
Exemple #18
0
    public void PackUpGUI()
    {
        GamePlayGUI.Instance.SetAndPlayAudioClip(PackUpAudioClip);
        GamePlayGUI.Instance.EnableEndTurnButton(true);


        foreach (GameObject abilityButton in AbilityButtons)
        {
            StartCoroutine(LerpToPosition(abilityButton, abilityButton.transform.position, AbilitySelectButton.transform.position,
                                          PackingAnimationCurve));
            abilityButton.SetActive(false);
        }
        State = _State.IndexSelected;
    }
Exemple #19
0
    protected override void LateUpdate()
    {
        _State _state = new _State()
        {
            targetVelocity = targetVelocity,
            velocity       = velocity,
            grounded       = grounded,
            groundNormal   = groundNormal,
        };

        currentInverseFrames += () => {
            targetVelocity = _state.targetVelocity;
            velocity       = _state.velocity;
            grounded       = _state.grounded;
            groundNormal   = _state.groundNormal;
        };
        base.LateUpdate();
    }
Exemple #20
0
    IEnumerator Bite()
    {
        if (_state.Equals(_State.ATTACK_BITE))
        {
            SetAnimation("attack_bite");

            yield return(new WaitForSeconds(0.41f));

            _state = _State.RETREAT;
        }
        if (_state.Equals(_State.IDLE_BITE))
        {
            SetAnimation("attack_idle");

            yield return(new WaitForSeconds(0.41f));

            _state = _State.IDLE;
        }
    }
Exemple #21
0
    void ProcessInput()
    {
        if (Input.touchCount > 0 || Input.GetMouseButton(0))
        {
            // Construct a ray from the current touch coordinates
            if (_state != _State.ATTACK && _state != _State.RETREAT)
            {
                _state = _State.TRANSITION;

                StopAllCoroutines();
                StartCoroutine(Transition());

                collider.offset = new Vector2(0.05f, 1.61f);
            }
            else
            {
                _state = _State.ATTACK;
            }
        }
    }
Exemple #22
0
        void ProjectileHitDelay()
        {
            if (projectileDestroyDelay <= 0)          //Destroy(thisObj);
            {
                ObjectPoolManager.Unspawn(thisObj);
                return;
            }

            state = _State.Hit;

            if (thisCollider != null)
            {
                thisCollider.enabled = false;
            }

            if (hideObject != null)
            {
                hideObject.SetActive(false);
            }
            ObjectPoolManager.Unspawn(thisObj, projectileDestroyDelay);
        }
Exemple #23
0
    IEnumerator Transition()
    {
        if (_state.Equals(_State.TRANSITION))
        {
            SetAnimation("attack_trans");
            //uAnimator.Speed = 10;

            yield return(new WaitForSeconds(0.05f));

            _state = _State.ATTACK;
        }
        if (_state.Equals(_State.TRANSITION_BACK))
        {
            SetAnimation("attack_trans");
            uAnimator.Speed = -1.0f;
            yield return(new WaitForSeconds(0.05f));

            uAnimator.Speed = 1;
            _state          = _State.IDLE;
        }
    }
Exemple #24
0
    void AttackAndRetreat()
    {
        if (_state.Equals(_State.ATTACK) || _state.Equals(_State.RETREAT))
        {
            if (currentPlayingAnimation != "attack")
            {
                SetAnimation("attack");
            }

            MoveFlower();
            if (transform.localPosition.y > 6.49f && _state.Equals(_State.ATTACK))
            {
                _state = _State.RETREAT;
            }

            if (transform.localPosition.y < 0 && _state.Equals(_State.RETREAT))
            {
                transform.localPosition = new Vector2(0, 0);
                _state = _State.TRANSITION_BACK;
            }
        }
    }
Exemple #25
0
        private Rooted(
            JSContext managedContext,
            JSContextPtr context,
            T value
            )
        {
            if (context.IsZero)
            {
                throw new ArgumentNullException("context");
            }

            // HACK: Attempt to locate a managed context for a raw pointer if that's all we have.
            // This lets us finalize safely.
            if (managedContext == null)
            {
                managedContext = JSContext.FromPointer(context);
            }

            if (managedContext != null)
            {
                ManagedContextReference = managedContext.WeakSelf;
            }
            else
            {
                ManagedContextReference = null;
            }

            Context = context;

            State = new _State(value);
            Pin   = GCHandle.Alloc(State, GCHandleType.Pinned);
            Root  = new JSRootPtr(Pin.AddrOfPinnedObject());

            if (!default(T).AddRoot(context, Root))
            {
                throw new Exception("Failed to add root");
            }
        }
Exemple #26
0
    public void UnpackGUI()
    {
        GamePlayGUI.Instance.SetAndPlayAudioClip(UnpackAudioClip);
        GamePlayGUI.Instance.EnableEndTurnButton(false);
        foreach (GameObject abilityButton in AbilityButtons)
        {
            abilityButton.SetActive(true);
        }

        State            = _State.IndexNotSelected;
        CurrentAbilities = GetCurrentAbilities();

        int i = 0;

        foreach (GameObject abilityButton in AbilityButtons)
        {
            abilityButton.GetComponent <Image>().overrideSprite = CurrentAbilities[i].Icon;

            StartCoroutine(LerpToPosition(abilityButton, abilityButton.transform.position, UnpackedPositions[i],
                                          UnpackingAnimationCurve));

            i++;
        }
    }
Exemple #27
0
        // Update is called once per frame
        void Update()
        {
            //if the shootobject is not in the shot state, dont continue
            if(type!=_SOType.Beam && state!=_State.Shot) return;

            float travelDistance=GetRangePerFrame();	//get the distance the shootobject travelled in this frame

            //do a sphere-cast to limit the travel distance in this frame so we dont over-shoot anything the shootobject might hit
            RaycastHit hit;
            if(Physics.SphereCast(thisT.position, hitRadius, thisT.forward, out hit, travelDistance, mask)){
                travelDistance=Vector3.Distance(thisT.position, hit.point);
            }

            if(type==_SOType.Simple){
                travelledDistance+=travelDistance;
                thisT.Translate(Vector3.forward * travelDistance);
                if(Time.time-shootTime>destroyTime) Hit();
                if(travelledDistance>srcRange) OnTriggerEnter(null);
            }
            if(type==_SOType.Homing){
                if(targetUnit!=null){
                    targetPos=targetUnit.thisT.position;

                    Vector3 thisTempPos=thisT.position;
                    thisTempPos.y=targetPos.y;
                    Quaternion tgtRot=Quaternion.LookRotation(targetPos-thisTempPos);

                    //if the target is too far off angle
                    if(Mathf.Abs(thisT.rotation.eulerAngles.y-tgtRot.eulerAngles.y)>65){
                        targetPos=thisT.TransformPoint(0, 0, speed);
                        targetPos.y=targetUnit.thisT.position.y;
                        targetUnit=null;
                    }
                    else if(Time.time-shootTime>trackingDuration){
                        targetUnit=null;
                        targetPos+=new Vector3(Random.value-0.5f, 0, Random.value-0.5f)*2*spread/2;
                    }
                }

                float currentDist=Vector3.Distance(thisT.position, targetPos);

                float timeMultipler=(speed/initialDist)*0.125f;
                curveMod+=Time.deltaTime*timeMultipler;
                timeSinceFire+=Time.deltaTime*timeMultipler;

                dummyPos=Vector3.Lerp(dummyPos, targetPos, timeSinceFire);

                Quaternion wantedRot=Quaternion.LookRotation(dummyPos-thisT.position);
                thisT.rotation=Quaternion.Slerp(thisT.rotation, wantedRot, Time.deltaTime*speed*(1.5f+curveMod));

                thisT.Translate(Vector3.forward * travelDistance);

                if(currentDist<hitRadius) OnTriggerEnter(null);
            }
            else if(type==_SOType.Beam){
                if(shootThrough) travelDistance=GetRangePerFrame();

                if(line!=null){
                    line.SetPosition(0, new Vector3(0, 0, 0));
                    line.SetPosition(1, new Vector3(0, 0, travelDistance));
                }

                if(!shootThrough){
                    if(hit.collider!=null){
                        if(Time.time-lastHitCD>0.2f){
                            if(state==_State.Shot) HitEffect(hit.point);
                            OnTriggerEnter(hit.collider);
                            lastHitCD=Time.time;
                        }
                        if(continousEffect) state=_State.Shot;
                    }
                }
                else{
                    if(Time.time-lastHitCD>0.1f){
                        lastHitCD=Time.time;
                        RaycastHit[] hitList=Physics.SphereCastAll(thisT.position, hitRadius, thisT.forward, travelDistance);

                        for(int i=0; i<hitList.Length; i++){
                            if(state==_State.Shot) HitEffect(hitList[i].point);
                            state=_State.Shot;
                            if(hitList[i].collider!=null) OnTriggerEnter(hitList[i].collider);
                        }

                        if(continousEffect) state=_State.Shot;
                    }
                }
            }
        }
Exemple #28
0
            internal void _BeginResponse(HttpResponse response, HttpStatusCode status, Action<HttpBuffer> ev_buffer, Action/*?*/ ev_done = null)
            {
                lock (_server._lock) {
                    if (_isdisposed) return;    // this is not the right place to throw
                    if (_state != _State.ResponseHeadersUserWait && _state != _State.RequestBodyUserWait)
                        throw new InvalidOperationException("invalid state for response body streaming (" + _state + ")");
                    if (_responsebody_streaming_started)
                        throw new InvalidOperationException("request body can only be streamed once");
                    if (_tx == null || _tx.Response != response)
                        throw new InvalidOperationException("this request object is not active");

                    _server.ev_debug("begin response");
                    _responsebody_buffer            = new ResponseBodyBuffer(this);
                    _responsebody_user_cb           = ev_buffer;
                    if (_responsebody_done_cb != null) throw new InvalidOperationException("resources may have leaked");
                    _responsebody_done_cb           = ev_done;

                    if (!response.Headers.ContentLength.HasValue && !_ishttp10) {
                        response.Headers.SetChunkedEncoding();
                    }

                    StringBuilder sb = new StringBuilder();
                    sb.AppendFormat("HTTP/{0} {1} {2}\r\n", (_ishttp10?"1.0":"1.1"), (int)status, _Utils.Stringify(status));
                    response.Headers.Write(sb, response.Cookies.Values);

                    _server.ev_debug("{0}", sb.ToString());
                    _server.ev_debug("--------------------------------------");

                    _responsebody_left = response.Headers.ContentLength ?? -1;
                    _writebytes        = Encoding.UTF8.GetBytes(sb.ToString());
                    _writecount        = _writebytes.Length;
                    _writeoff          = 0;
                    if (_state == _State.RequestBodyUserWait) {         // if we are still waiting for the user to read the request body, dump it
                        _state = _State.RequestBodyDump;
                    } else {
                        _state = _State.SendResponseHeaders;
                    }
                    _HandleCurrentState();
                }
            }
Exemple #29
0
        //called when shootobject hit something
        void OnTriggerEnter(Collider col)
        {
            if(state==_State.Hit) return;	//if the shootobject has hit something before this, return

            //if the shootobject hits another shootobject from friendly unit
            if(!GameControl.SOHitFriendly() && col!=null){
                if(srcLayer==col.gameObject.layer) return;
            }

            //register the state of the shootobject as hit
            state=_State.Hit;

            TDS.CameraShake(impactCamShake);

            //when hit a shootObject
            if(col!=null && col.gameObject.layer==TDS.GetLayerShootObject()){
                //if this is a beam shootobject, inform the other shootobject that it has been hit (beam doesnt use a collider)
                if(type==_SOType.Beam) col.gameObject.GetComponent<ShootObject>().Hit();
            }

            //when hit a collectible, destroy the collectible
            if(col!=null && col.gameObject.layer==TDS.GetLayerCollectible()){
                ObjectPoolManager.Unspawn(col.gameObject);
                return;
            }

            //if there's a attack instance (means the shootobject has a valid attacking stats and all)
            if(attInstance!=null){
                float aoeRadius=attInstance.aStats.aoeRadius;

                //for area of effect hit
                if(aoeRadius>0){
                    Unit unitInstance=null;

                    //get all the potental target in range
                    Collider[] cols=Physics.OverlapSphere(thisT.position, aoeRadius);
                    for(int i=0; i<cols.Length; i++){
                        //if the collider in question is the collider the shootobject hit in the first place, apply the full attack instance
                        if(cols[i]==col){
                            unitInstance=col.gameObject.GetComponent<Unit>();
                            if(unitInstance!=null) unitInstance.ApplyAttack(attInstance.Clone());
                            continue;
                        }

                        //no friendly fire, then skip if the target is a friendly unit
                        if(!GameControl.SOHitFriendly()){
                            if(cols[i].gameObject.layer==srcLayer) continue;
                        }

                        unitInstance=cols[i].gameObject.GetComponent<Unit>();

                        //create a new attack instance and mark it as aoe attack, so diminishing aoe can be applied if enabled
                        AttackInstance aInstance=attInstance.Clone();
                        aInstance.isAOE=true;
                        aInstance.aoeDistance=Vector3.Distance(thisT.position, cols[i].transform.position);

                        //apply the attack
                        if(unitInstance!=null) unitInstance.ApplyAttack(aInstance);
                    }
                }
                else{
                    if(col!=null){
                        //get the unit and apply the attack
                        Unit unitInstance=col.gameObject.GetComponent<Unit>();
                        if(unitInstance!=null) unitInstance.ApplyAttack(attInstance);
                    }
                }

                if(col!=null){
                    //apply impact force to the hit object
                    Vector3 impactDir=Quaternion.Euler(0, thisT.eulerAngles.y, 0)*Vector3.forward;
                    TDSPhysics.ApplyAttackForce(thisT.position, impactDir, col.gameObject, attInstance.aStats);
                }
            }

            //add collider to the condition so the shootobject wont split if the shootObject didnt hit anything (it could have just reach the range limit)
            if(splitUponHit && col!=null) Split(col);

            Hit();
        }
Exemple #30
0
        void ProjectileHitDelay()
        {
            if(projectileDestroyDelay<=0){//Destroy(thisObj);
                ObjectPoolManager.Unspawn(thisObj);
                return;
            }

            state=_State.Hit;

            if(thisCollider!=null) thisCollider.enabled=false;

            if(hideObject!=null) hideObject.SetActive(false);
            ObjectPoolManager.Unspawn(thisObj, projectileDestroyDelay);
        }
Exemple #31
0
        //also get called (on the projectile instance) when a projectile being hit by a beam
        public void Hit()
        {
            if(type==_SOType.Simple || type==_SOType.Homing){
                HitEffect(thisT.position);
                if(!shootThrough) ProjectileHitDelay();
                else state=_State.Shot;

                if(Time.time-shootTime>destroyTime || travelledDistance>srcRange) ProjectileHitDelay();
            }
            else if(type==_SOType.Point){
                HitEffect(thisT.position+new Vector3(0, 0.2f, 0));
                ObjectPoolManager.Unspawn(thisObj);
            }
        }
Exemple #32
0
        //function call to fire the object
        public void Shoot(int srcL, float srcR, Transform shootPoint, AttackInstance aInstance=null, AimInfo aimInfo=null)
        {
            Init();

            thisObj.SetActive(true);

            //cached all the passed information lcoally
            attInstance=aInstance;
            srcLayer=srcL;	//the layer of the shooting unit (so we know it's from player or AI)
            srcRange=srcR;	//the range of the shooting unit (so we know when to stop)

            state=_State.Shot;
            shootTime=Time.time;	//to track how long the shoot object is has been
            travelledDistance=0;	//to track how far the shoot object is has been fired

            //if there's any hideObject, set it to true (it's probably set to false when the shoot-object last hit something)
            if(hideObject!=null) hideObject.SetActive(true);

            //instantiate the shoot effect
            ShootEffect(thisT.position, thisT.rotation);

            if(type==_SOType.Simple || type==_SOType.Homing){
                //if(aInstance!=null && thisCollider.enabled){
                    //~ Physics.IgnoreCollision(aInstance.srcUnit.GetCollider(), thisObj.GetComponent<Collider>(), true);
                    //Debug.Log("collision avoidance with shooter unresolved");
                    //Physics.IgnoreCollision(srcCollider, thisCollider, true);
                //}

                // for homing shootobject, the shootobject needs to be aiming at some position, or a specific unit
                if(type==_SOType.Homing){
                    if(aimInfo.targetT!=null) targetUnit=aimInfo.unit;

                    targetPos=aimInfo.hitPoint+new Vector3(Random.value-0.5f, 0, Random.value-0.5f)*2*spread;
                    initialPos=shootPoint.position;
                    initialDist=Vector3.Distance(targetPos, initialPos);

                    curveMod=Random.Range(0, 2f);
                    dummyPos=thisT.TransformPoint(Vector3.forward*speed*5);
                    dummyPos=(targetPos+dummyPos)/2;
                }
            }
            else if(type==_SOType.Beam){
                //if(attachedToShootPoint) transform.parent=shootPoint;
                thisT.parent=shootPoint;
                ObjectPoolManager.Unspawn(thisObj, beamDuration-.01f);
            }
            else if(type==_SOType.Point){
                StartCoroutine(PointRoutine(aimInfo));
            }

            //update the layermask used to do the hit detection in accordance to rules set in GameControl
            UpdateSphereCastMask(!GameControl.SOHitFriendly(), !GameControl.SOHitShootObject(), !GameControl.SOHitCollectible());
        }
 void _G8_Lower_Curtain_Menu()
 {
     _state = _State.G8_LOWERING_CURTAIN;
     Curtain._singleton._EarRequest(Curtain._Request.Activate);
     Curtain._singleton._EarRequest(Curtain._Request.Lower_Curtain);
 }
Exemple #34
0
            void ev_requestbodyready()
            {
                //
                // There are four strategies for handling the request body
                //
                // (1) Content-Length is 0: Nothing to do
                //
                // (2) Content-Length > 0 + Content-Type is application/x-www-form-urlencoded: Read it now.
                //
                // (3) Content-Length > 0 + Content-Type is application/x-www-urlencoded: Read it now.
                //
                // (4) Content-Length > 0 + Content-Type is something else: Let the user stream the request body.
                //
                // (5) Transfer-Encoding is chunked: Fail with NotImplemented (for now--may support this in future)
                //

                _server.ev_debug("request body ready");

                if (_tx.Request.Headers.IsChunkedEncoding) {
                    _Fail(HttpStatusCode.NotImplemented);               // case (4) -- fail
                    return;
                }

                var contentlength = _tx.Request.Headers.ContentLength ?? 0;
                if (contentlength == 0) {
                    _state = _State.ResponseHeadersUserWait;
                    _server.ev_debug("    ==> case 1 (nothing to do)");
                    ev_requestready();                                    // case (1) -- nothing to do
                } else {
                    if (_tx.Request.Method == HttpMethod.Post &&
                        _tx.Request.Headers.ContentType != null &&
                        _tx.Request.Headers.ContentType.Contains("multipart/form-data")) {

                        _server.ev_debug("    ==> case 1 (multipart)");
                        var boundary           = _ParseBoundary(_tx.Request.Headers.ContentType);
                        _requestbody_multipart = new HttpMultiPartFormDataHandler(boundary, _tx.Request.Headers.ContentEncoding);
                        _requestbody_left      = contentlength;
                        _state                 = _State.RequestBodyMultiPart;     // case (2) -- read request body now

                    } else if (_tx.Request.Method == HttpMethod.Post &&
                        _tx.Request.Headers.ContentType != null &&
                        _tx.Request.Headers.ContentType.Contains("application/x-www-form-urlencoded")) {

                        _server.ev_debug("    ==> case 1 (urlencoded)");

                        _requestbody_full = new MemoryStream();
                        _requestbody_left = contentlength;
                        _state            = _State.RequestBodyFull;     // case (2) -- read request body now

                    } else {
                        _server.ev_debug("    ==> case 1 (userstream)");
                        _state = _State.RequestBodyUserWait;            // case (3) -- let user stream request body
                        _requestbody_left = contentlength;
                        _requestbody_streaming_started = false;
                        _tx.Request.SetStreamingRequestBody(true);
                        ev_requestready();
                    }
                }
            }
Exemple #35
0
 void _Send100Continue()
 {
     _state      = _State.Send100Continue;
     _writebytes = Encoding.UTF8.GetBytes("HTTP/1.1 100 Continue\r\n\r\n");
     _writeoff   = 0;
     _writecount = _writebytes.Length;
 }
Exemple #36
0
            internal void BeginStreamingRequestBody(HttpRequest request, Action<HttpBuffer> cb_buffer)
            {
                lock (_server._lock) {
                    if (_isdisposed) return;    // this is not the right place to throw
                    if (_state != _State.RequestBodyUserWait)
                        throw new InvalidOperationException("invalid state for request body streaming");
                    if (_requestbody_streaming_started)
                        throw new InvalidOperationException("request body can only be streamed once");
                    if (_tx == null || _tx.Request != request)
                        throw new InvalidOperationException("this request object is not active");

                    _requestbody_streaming_started = true;
                    _requestbody_buffer            = new RequestBodyBuffer(this);
                    _requestbody_user_cb           = cb_buffer;
                    _state                         = _State.RequestBodyUserRead;
                    _HandleCurrentState();
                }
            }
 void _R1_Show_Results()
 {
     _state = _State.G7_SHOWING_RESULTS;
     Results._singleton._EarRequest(Results._Request.Activate);
     Results._singleton._Hand_points(GameplayManagerNew._points);
 }
Exemple #38
0
            void _Fail(HttpStatusCode code)
            {
                var response      = string.Format("HTTP/1.1 {0} {1}\r\nContent-Length: 0\r\n\r\n", (int)code, _Utils.Stringify(code));
                var responsebytes = Encoding.UTF8.GetBytes(response);

                _state      = _State.Failure;
                _writeoff   = 0;
                _writecount = responsebytes.Length;
                _writebytes = responsebytes;
            }
Exemple #39
0
 void ev_requestbody_user_buffer()
 {
     int toread = (int)Math.Min(_requestbody_left, _readcount);
     _requestbody_buffer.Buffer       = _readbuf;
     _requestbody_buffer.Offset       = _readoff;
     _requestbody_buffer.Count        = toread;
     _requestbody_buffer.IsLastBuffer = _requestbody_left == toread;
     _requestbody_left -= toread;
     _readoff          += toread;
     _readcount        -= toread;
     _state = _State.RequestBodyUserWait;
     _server._DispatchCallback(() => _requestbody_user_cb(_requestbody_buffer));
 }
Exemple #40
0
            void _RequestBodyBufferComplete()
            {
                lock (_server._lock) {
                    if (_isdisposed) return;    // this is not the right place to throw

                    if (_state != _State.RequestBodyUserWait)
                        throw new InvalidOperationException("request is not waiting for buffer complete");

                    if (_requestbody_left > 0) {
                        _state = _State.RequestBodyUserRead;
                        _HandleCurrentState();
                    } else {
                        _state = _State.ResponseHeadersUserWait;
                        _requestbody_buffer  = null;
                        _requestbody_user_cb = null;
                        _HandleCurrentState();
                    }
                }
            }
Exemple #41
0
 void ev_need100continue()
 {
     if (!_server.ev_need100continue(_tx)) {
         _Send100Continue();
     } else {
         _state = _State.Send100ContinueUserWait;
     }
 }
        /// <summary>
        /// Lädt alle Profile erneut.
        /// </summary>
        internal static void Reset()
        {
            // Report
            Tools.ExtendedLogging( "Reloading Profile List" );

            // Forward to profile manager
            ProfileManager.Refresh();

            // Create a new state
            var newState = new _State();

            // List of profiles
            var profiles = new List<Profile>();

            // Load the setting
            var profileNames = VCRConfiguration.Current.ProfileNames;
            if (!string.IsNullOrEmpty( profileNames ))
                foreach (var profileName in profileNames.Split( '|' ))
                {
                    // Try to locate
                    var profile = ProfileManager.FindProfile( profileName.Trim() );
                    if (profile == null)
                    {
                        // This is not goot
                        VCRServer.LogError( Properties.Resources.InternalError_NoProfile, profileName.Trim() );

                        // Next
                        continue;
                    }

                    // Report
                    Tools.ExtendedLogging( "Using Profile {0}", profile.Name );

                    // Remember
                    profiles.Add( profile );

                    // Create the dictionary of sources
                    var sourcesByIdentifier = new Dictionary<SourceIdentifier, SourceSelection>();
                    var sourcesByKey = new Dictionary<string, SourceSelection>();

                    // Load by name
                    foreach (var byDisplayName in profile.AllSourcesByDisplayName)
                        sourcesByKey[byDisplayName.DisplayName] = byDisplayName;

                    // Remember it
                    newState.SourceByIdentifierMap[profile.Name] = sourcesByIdentifier;
                    newState.SourceBySelectionMap[profile.Name] = sourcesByKey;

                    // Load list
                    foreach (var source in sourcesByKey.Values)
                    {
                        // Just remember by identifier
                        sourcesByIdentifier[source.Source] = source;

                        // Correct back the name
                        source.DisplayName = ((Station)source.Source).FullName;
                    }
                }

            // Fill it
            foreach (var profileMap in newState.SourceBySelectionMap.Values)
                foreach (var mapEntry in profileMap)
                    newState.UniqueNameBySelectionMap[mapEntry.Value.SelectionKey] = mapEntry.Key;

            // Add all qualified names to allow semi-legacy clients to do a unique lookup
            foreach (var profileMap in newState.SourceBySelectionMap.Values)
                foreach (var source in profileMap.ToList())
                    if (!source.Key.Equals( source.Value.DisplayName ))
                    {
                        // Unmap the station
                        var station = (Station)source.Value.Source;

                        // Enter special notation
                        profileMap[$"{station.Name} {station.ToStringKey()} [{station.Provider}]"] = source.Value;
                    }

            // Use all
            newState.Profiles = profiles.ToArray();
            newState.ProfileMap = profiles.ToDictionary( profile => profile.Name, newState.ProfileMap.Comparer );

            // Report
            Tools.ExtendedLogging( "Activating new Profile Set" );

            // Use the new state
            CurrentState = newState;
        }
Exemple #43
0
            void ev_writedone()
            {
                if (_state == _State.Failure) {
                    Dispose();

                } else if (_state == _State.Send100Continue) {
                    ev_requestbodyready();
                    _HandleCurrentState();

                } else if (_state == _State.SendResponseBody) {
                    _state  = _State.ResponseBodyUserWait;
                    var cb  = _responsebody_user_cb;
                    var buf = _responsebody_buffer;
                    _server._DispatchCallback(() => cb(buf));

                } else if (_state == _State.SendResponseBodyLast) {
                    // clear out all state
                    _tx                             = null;
                    _readoff                        = 0;
                    _readcount                      = 0;
                    _readbuf                        = new byte[4096];
                    _readoff                        = 0;
                    _readcount                      = 0;
                    _headerstate                    = _HeaderState.FirstLine;
                    _linems                         = new MemoryStream();
                    _firstline                      = null;
                    _headerlines                    = new List<string>();
                    _writeoff                       = 0;
                    _writecount                     = 0;
                    _writebytes                     = null;
                    _requestbody_left               = 0;
                    _requestbody_full               = null;
                    _requestbody_multipart          = null;
                    _requestbody_streaming_started  = false;
                    _requestbody_buffer             = null;
                    _requestbody_user_cb            = null;
                    _responsebody_streaming_started = false;
                    _responsebody_buffer            = null;
                    _responsebody_user_cb           = null;
                    _responsebody_done_cb           = null;
                    _responsebody_left              = -1;
                    _state                          = _State.RequestHeaders;

                    if (_isconnectionclose || _ishttp10) {
                        Dispose();
                    } else {
                        _HandleCurrentState();
                    }

                } else if (_state == _State.SendResponseHeaders) {
                    _state = _State.ResponseBodyUserWait;
                    _server._DispatchCallback(() => _responsebody_user_cb(_responsebody_buffer));

                } else {
                    throw new InvalidOperationException();
                }
            }
Exemple #44
0
 //Characters will update first, that way components (like injuries) can override and modify behaviour.
 protected virtual void OnPhaseStart(TurnManager.TeamColor CurrentTeamTurn, int TurnCount)
 {
     CurrentState = _State.Idle;
 }
Exemple #45
0
 void ev_requestbody_dump_buffer()
 {
     int toread = (int)Math.Min(_requestbody_left, _readcount);
     _requestbody_left -= toread;
     _readoff          += toread;
     _readcount        -= toread;
     if (_requestbody_left == 0) {
         _state = _State.SendResponseHeaders;
     }
 }
Exemple #46
0
 void ev_requestbody_full_buffer()
 {
     int toread = (int)Math.Min(_requestbody_left, _readcount);
     _requestbody_full.Write(_readbuf, _readoff, toread);
     _requestbody_left -= toread;
     _readoff          += toread;
     _readcount        -= toread;
     if (_requestbody_left == 0) {
         _state = _State.ResponseHeadersUserWait;
         _tx.Request.SetFormBody(Encoding.UTF8.GetString(_requestbody_full.ToArray()));
         ev_requestready();
     }
 }
Exemple #47
0
            void _ResponseBodyBufferComplete()
            {
                lock (_server._lock) {
                    if (_isdisposed) return;    // this is not the right place to throw

                    if (_state != _State.ResponseBodyUserWait)
                        throw new InvalidOperationException("response is not waiting for buffer complete (state=" + _state + ")");

                    bool chunked = false;

                    if (_responsebody_left != -1) {
                        if (_responsebody_buffer.Count > _responsebody_left) {
                            Dispose();
                            throw new InvalidOperationException("sent more data than content length");
                        }
                        if (_responsebody_buffer.IsLastBuffer && _responsebody_buffer.Count != _responsebody_left) {
                            Dispose();
                            throw new InvalidOperationException("sent last buffer before reaching content length");
                        }
                        _responsebody_left -= _responsebody_buffer.Count;
                    } else if (!_ishttp10) {
                        chunked = true;
                    }

                    if (chunked) {
                        // if we have no content length + are not http 1.0, then chunk it
                        MemoryStream ms = new MemoryStream();
                        byte[] before = Encoding.ASCII.GetBytes(String.Format("{0:X}\r\n", _responsebody_buffer.Count));
                        byte[] after = Encoding.ASCII.GetBytes("\r\n");
                        ms.Write(before, 0, before.Length);
                        ms.Write(_responsebody_buffer.Buffer, _responsebody_buffer.Offset, _responsebody_buffer.Count);
                        ms.Write(after, 0, after.Length);
                        if (_responsebody_buffer.IsLastBuffer) {
                            byte[] trailer = Encoding.ASCII.GetBytes("0\r\n\r\n");
                            ms.Write(trailer, 0, trailer.Length);
                            _FireResponseBodyDone();
                        }
                        //_server.ev_debug(Encoding.UTF8.GetString(ms.ToArray()));
                        //_server.ev_debug("--------------------------------------");
                        _writebytes = ms.ToArray();
                        _writeoff   = 0;
                        _writecount = _writebytes.Length;
                    } else {
                        //_server.ev_debug(Encoding.UTF8.GetString(_responsebody_buffer.Buffer, _responsebody_buffer.Offset, _responsebody_buffer.Count));
                        //_server.ev_debug("--------------------------------------");
                        // not chunked; just write the data
                        _writebytes = _responsebody_buffer.Buffer;
                        _writeoff   = _responsebody_buffer.Offset;
                        _writecount = _responsebody_buffer.Count;
                    }

                    if (_responsebody_buffer.IsLastBuffer) {
                        _FireResponseBodyDone();
                        _state      = _State.SendResponseBodyLast;
                    } else {
                        _state      = _State.SendResponseBody;
                    }

                    _HandleCurrentState();
                }
            }
        /// <summary>
        /// Lädt alle Profile erneut.
        /// </summary>
        internal static void Reset()
        {
            // Report
            Tools.ExtendedLogging("Reloading Profile List");

            // Forward to profile manager
            ProfileManager.Refresh();

            // Create a new state
            var newState = new _State();

            // List of profiles
            var profiles = new List <Profile>();

            // Load the setting
            var profileNames = VCRConfiguration.Current.ProfileNames;

            if (!string.IsNullOrEmpty(profileNames))
            {
                foreach (var profileName in profileNames.Split('|'))
                {
                    // Try to locate
                    var profile = ProfileManager.FindProfile(profileName.Trim());
                    if (profile == null)
                    {
                        // This is not goot
                        VCRServer.LogError(Properties.Resources.InternalError_NoProfile, profileName.Trim());

                        // Next
                        continue;
                    }

                    // Report
                    Tools.ExtendedLogging("Using Profile {0}", profile.Name);

                    // Remember
                    profiles.Add(profile);

                    // Create the dictionary of sources
                    var sourcesByIdentifier = new Dictionary <SourceIdentifier, SourceSelection>();
                    var sourcesByKey        = new Dictionary <string, SourceSelection>();

                    // Load by name
                    foreach (var byDisplayName in profile.AllSourcesByDisplayName)
                    {
                        sourcesByKey[byDisplayName.DisplayName] = byDisplayName;
                    }

                    // Remember it
                    newState.SourceByIdentifierMap[profile.Name] = sourcesByIdentifier;
                    newState.SourceBySelectionMap[profile.Name]  = sourcesByKey;

                    // Load list
                    foreach (var source in sourcesByKey.Values)
                    {
                        // Just remember by identifier
                        sourcesByIdentifier[source.Source] = source;

                        // Correct back the name
                        source.DisplayName = ((Station)source.Source).FullName;
                    }
                }
            }

            // Fill it
            foreach (var profileMap in newState.SourceBySelectionMap.Values)
            {
                foreach (var mapEntry in profileMap)
                {
                    newState.UniqueNameBySelectionMap[mapEntry.Value.SelectionKey] = mapEntry.Key;
                }
            }

            // Add all qualified names to allow semi-legacy clients to do a unique lookup
            foreach (var profileMap in newState.SourceBySelectionMap.Values)
            {
                foreach (var source in profileMap.ToList())
                {
                    if (!source.Key.Equals(source.Value.DisplayName))
                    {
                        // Unmap the station
                        var station = (Station)source.Value.Source;

                        // Enter special notation
                        profileMap[$"{station.Name} {station.ToStringKey()} [{station.Provider}]"] = source.Value;
                    }
                }
            }

            // Use all
            newState.Profiles   = profiles.ToArray();
            newState.ProfileMap = profiles.ToDictionary(profile => profile.Name, newState.ProfileMap.Comparer);

            // Report
            Tools.ExtendedLogging("Activating new Profile Set");

            // Use the new state
            CurrentState = newState;
        }
Exemple #49
0
 void ev_requestbody_multipart_buffer()
 {
     int toread = (int)Math.Min(_requestbody_left, _readcount);
     _requestbody_multipart.HandleData(_tx.Request, _readbuf, _readoff, toread);
     _requestbody_left -= toread;
     _readoff          += toread;
     _readcount        -= toread;
     if (_requestbody_left == 0) {
         _state = _State.ResponseHeadersUserWait;
         ev_requestready();
     }
 }