public void FindBodyType(Transform body)
    {
        GameLoopManager.Instance.UpdatePlayer -= OnUpdate;

        if (_humanoid != null)
        {
            _humanoid.SetPlayer(null);
            _humanoid      = null;
            SetCurrentBody = E_Bodies.PLAYER;
        }
        else if (_ball != null)
        {
            _ball.SetPlayer(null);
            _ball          = null;
            SetCurrentBody = E_Bodies.PLAYER;
        }

        switch (body.gameObject.layer)
        {
        case 8:
            _humanoid = body.GetComponent <HumanoidBody>();
            this.transform.position = body.transform.position;
            this.transform.SetParent(body);
            _humanoid.SetPlayer(this);
            SetCurrentBody = E_Bodies.HUMANOID;
            _body          = body;
            _bodyCol       = body.GetComponent <Collider2D>();
            GameLoopManager.Instance.UpdatePlayer += OnUpdate;
            break;

        case 9:
            _ball = body.GetComponent <BallBody>();
            this.transform.position = body.transform.position;
            this.transform.SetParent(body);
            _ball.SetPlayer(this);
            SetCurrentBody = E_Bodies.BALL;
            _body          = body;
            _bodyCol       = body.GetComponent <Collider2D>();
            GameLoopManager.Instance.UpdatePlayer += OnUpdate;
            break;

        case 10:
            break;

        case 11:
            break;

        case 12:
            break;

        case 13:
            break;

        case 14:
            break;

        default:
            break;
        }
    }
示例#2
0
 void IBallStates.Init(BallBody self)
 {
     _self               = self;
     _speed              = self.GetSpeed;
     _accelerationSpeed  = self.GetAccSpeed;
     _desallerationSpeed = self.GetDesaccSpeed;
 }
示例#3
0
 protected virtual void Start()
 {
     body            = GetComponent <BallBody>();
     body.MoveEvent += OnAction;
     body.EndEvent  += OnEnd;
     action_ready    = true;
     in_action       = false;
 }
示例#4
0
 private void Move(MovingDiractions Diraction)
 {
     if (spentEnergy < Settings.levelEnergy)
     {
         BallBody.AddForce(NormalizedForceVectorByDiraction(Diraction));
         spentEnergy += NormalizedForceVectorByDiraction(Diraction).magnitude *Settings.energyMultiplyer;
         Logger.UpdateContent(UILogDataTypes.EnergyAmount, "Energy spent: " + spentEnergy + "/" + Settings.levelEnergy);
     }
     else
     {
         Defeat();
     }
 }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        switch (collision.gameObject.layer)
        {
        case 8:
            HumanoidBody body = collision.GetComponent <HumanoidBody>();

            if (body.GetStatus == E_BodyStatus.POSSESSED)
            {
                _body.bodyType = RigidbodyType2D.Dynamic;
                gameObject.SetActive(false);
            }
            break;

        case 9:
            BallBody ball = collision.GetComponent <BallBody>();

            if (ball.GetStatus == E_BodyStatus.POSSESSED)
            {
                _body.bodyType = RigidbodyType2D.Dynamic;
                gameObject.SetActive(false);
            }
            break;

        case 10:
            //set
            break;

        case 11:
            //set
            break;

        case 12:
            //set
            break;

        case 13:
            //set
            break;

        case 14:
            //set
            break;

        default:
            break;
        }
    }
示例#6
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        switch (collision.gameObject.layer)
        {
        case 8:
            HumanoidBody body = collision.GetComponent <HumanoidBody>();

            if (body.GetStatus == E_BodyStatus.POSSESSED)
            {
                Debug.Log("you win");
                GameLoopManager.Instance.SetIsPaused = true;
            }
            break;

        case 9:
            BallBody ball = collision.GetComponent <BallBody>();

            if (ball.GetStatus == E_BodyStatus.POSSESSED)
            {
                GameLoopManager.Instance.SetIsPaused = true;
                Debug.Log("you win");
            }
            break;

        case 10:
            //set
            break;

        case 11:
            //set
            break;

        case 12:
            //set
            break;

        case 13:
            //set
            break;

        case 14:
            //set
            break;

        default:
            break;
        }
    }
示例#7
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        switch (collision.gameObject.layer)
        {
        case 8:
            HumanoidBody body = collision.GetComponent <HumanoidBody>();

            if (body.GetStatus == E_BodyStatus.POSSESSED)
            {
                CPsManager.Instance.SetLastHitCP = this;
                gameObject.SetActive(false);
            }
            break;

        case 9:
            BallBody ball = collision.GetComponent <BallBody>();

            if (ball.GetStatus == E_BodyStatus.POSSESSED)
            {
                CPsManager.Instance.SetLastHitCP = this;
                gameObject.SetActive(false);
            }
            break;

        case 10:
            //set
            break;

        case 11:
            //set
            break;

        case 12:
            //set
            break;

        case 13:
            //set
            break;

        case 14:
            //set
            break;

        default:
            break;
        }
    }
示例#8
0
文件: Ball.cs 项目: frodare/PivotPong
        public static Entity New(Scene scene)
        {
            var e = scene.createEntity("ball");

            e.addComponent(new Sprite(BallTexture(scene)));
            e.addComponent <CircleCollider>();

            BallBody body = new BallBody(scene);

            body.velocity = new Vector2(0, 0);
            e.addComponent(body);

            e.addComponent(new CircularBounds(Vector2.Zero, 300));

            return(e);
        }
示例#9
0
    private void Awake()
    {
        // Set up the reference.
        body = GetComponent <BallBody>();

        // get the transform of the main camera
        if (Camera.main != null)
        {
            cam = Camera.main.transform;
        }
        else
        {
            Debug.LogWarning(
                "Warning: no main camera found. Ball needs a Camera tagged \"MainCamera\", for camera-relative controls.");
            // we use world-relative controls in this case, which may not be what the user wants, but hey, we warned them!
        }
    }
示例#10
0
 public void Init(BallBody self)
 {
     _self = self;
 }
示例#11
0
 private void Move(Vector2 Diraction)
 {
     BallBody.AddForce(ForceVectorByDiraction(Diraction));
     //Functions.DrawTemporalLine(transform.position, transform.position + ForceVectorByDiraction(Diraction));
 }
示例#12
0
 private void Move(MovingDiractions Diraction)
 {
     BallBody.AddForce(ForceVectorByDiraction(Diraction));
 }
示例#13
0
 void IBallStates.Init(BallBody self)
 {
     _self = self;
 }