Ejemplo n.º 1
0
    public override void Start()
    {
        this.tag                  = "Player";
        skillList                 = AddCommponent <SkillEngine>();
        weaponSystem              = AddCommponent <WeaponEngine>();
        Shap                      = new CircleShap(new Fixed(0.25f), 8);
        rigibody.useCheck         = true;
        rigibody.useCheckCallBack = true;
        CanMove                   = true;
        if (IsLocalPlayer)
        {
            client.localPlayer = this;
            Debug.Log("client.localPlayer");
        }
        team  = 1;
        items = AddCommponent <ItemEngine>();
        //  ai=new AiEngine();
        //  ai.aiName="AI_test";

        // ai=AddCommponent<AiEngine>(ai);

        // ai.emenyTag="Zombie";
        base.Start();
        weaponSystem.AddWeapon(WeaponId.无战斗);
        skillList.AddSkill(SkillManager.GetSkill(SkillId.拳击右直));
    }
Ejemplo n.º 2
0
 public override void Update(TimeSpan elapsed)
 {
     WeaponEngine.Update(elapsed);
     if (AI != null)
     {
         AI.Update(elapsed);
     }
 }
Ejemplo n.º 3
0
        private void MeDied(object sender)
        {
            SoundPlayer.PlaySound("scream");
            WeaponEngine.SetWeapon <Weapons.Flowers>();
            Random     rnd   = new Random((int)DateTime.Now.Ticks);
            Storyboard board = rnd.Next(0, 1) == 1 ? _stbDeadLeft : _stbDeadRight;

            board.Begin();
        }
Ejemplo n.º 4
0
 public override void Die()
 {
     base.Die();
     if (HealthPoints < 1)
     {
         AI.Destroy();
         WeaponEngine.Empty();
     }
 }
Ejemplo n.º 5
0
        public ArmedNPC(UserControl content)
            : base(content)
        {
            Canvas weaponSurface = (Canvas)content.FindName("cnv_weaponSurface");

            if (weaponSurface == null)
            {
                throw new ArgumentNullException("No cnv_weaponSurface implemented!");
            }
            WeaponEngine = new WeaponEngine(weaponSurface);

            AI = new AIEngine();
        }
Ejemplo n.º 6
0
        override protected void FixedUpdate()
        {
            base.FixedUpdate();

            if (IsAlive())
            {
                float horizontal = Input.GetAxis("Horizontal");
                float vertical   = Input.GetAxis("Vertical");

                Vector2 mousePos = Camera.main.ScreenToWorldPoint(new Vector2(Input.mousePosition.x, Input.mousePosition.y));

                Move(horizontal, vertical);
                LookAt(mousePos.x, mousePos.y);

                if (currentWeapon != null)
                {
                    // TODO : handle joypad button
                    WeaponEngine weaponEngine = currentWeapon.GetComponent <WeaponEngine>();
                    // TODO ajouter controls manager pour switch clavier/sourie (lastInput = clavier OU stick)
                    Vector2 position  = new Vector2(transform.position.x, transform.position.y);
                    Vector2 direction = new Vector2(Input.GetAxis("RightStickX"), Input.GetAxis("RightStickY"));
                    if (direction.magnitude > 0)
                    {
                        weaponEngine.Aim(position + direction);
                        weaponEngine.Fire(gameObject, direction);
                    }
                    else
                    {
                        weaponEngine.Aim(mousePos);
                        if (Input.GetMouseButton(0))   // PRESSED
                        //Debug.Log("Pressed left.");
                        {
                            direction = mousePos - position;
                            weaponEngine.Fire(gameObject, direction);
                        }
                    }

                    if (Input.GetMouseButtonDown(1))   //CLICK
                    {
                        Debug.Log("Clicked right. ROULAAAAAADE");
                    }

                    if (Input.GetMouseButtonDown(2))
                    {
                        Debug.Log("Clicked middle.");
                    }
                }
            }
        }
Ejemplo n.º 7
0
        protected virtual void Equip(GameObject weapon)
        {
            if (currentWeapon != null)
            {
                currentWeapon.SetActive(false);
                Destroy(currentWeapon);
                currentWeapon = null;
            }

            currentWeapon = Instantiate(weapon, new Vector3(0, 0, 0), Quaternion.identity);
            WeaponEngine weaponEngine = currentWeapon.GetComponent <WeaponEngine>();

            weaponEngine.RegisterOwner(this.gameObject);
            currentWeapon.transform.SetParent(this.gameObject.transform.parent);
        }
Ejemplo n.º 8
0
        // Update is called once per frame
        protected override void FixedUpdate()
        {
            base.FixedUpdate();

            if (IsAlive())
            {
                GameObject player = GameObject.FindGameObjectWithTag("Player");
                GameObject core   = GameObject.FindGameObjectWithTag("Core");
                Vector3    move   = new Vector3();

                // TODO : shoot & jump occasionnaly
                if (player != null)
                {
                    move = player.transform.position - transform.position;
                    LookAt(player.transform.position.x, player.transform.position.y);
                    if (currentWeapon != null)
                    {
                        WeaponEngine weaponEngine = currentWeapon.GetComponent <WeaponEngine>();
                        weaponEngine.Aim(player.gameObject.transform.position);

                        if (shotEnabled)
                        {
                            shotEnabled = false;
                            weaponEngine.Fire(this.gameObject, player.transform.position - this.transform.position);
                        }
                    }
                }

                if (core != null)
                {
                    move = core.transform.position - transform.position;
                }
                Move(move.x, move.y);
            }
            else
            {
                // Move(0, 0); // empecher slide (a faire autrement)
            }
        }